NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/58270: tic(1) always creates files with mode 0666



>Number:         58270
>Category:       bin
>Synopsis:       tic(1) always creates files with mode 0666
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 20 07:45:00 +0000 2024
>Originator:     RVP
>Release:        NetBSD/amd64 10.99.10
>Organization:
>Environment:
NetBSD/amd64 10.99.10
>Description:
tic(1) doesn't honour user's umask. It always creates output files having mode 0666.


>How-To-Repeat:
$ umask 022; tic -x -o x.cdb /usr/share/misc/terminfo; ls -l x.cdb
-rw-rw-rw-  1 rvp  wheel  2006370 May 20 07:39 x.cdb
$ umask 077; tic -x -o x.cdb /usr/share/misc/terminfo; ls -l x.cdb
-rw-rw-rw-  1 rvp  wheel  2006370 May 20 07:39 x.cdb
$ 

>Fix:
diff -urN a/tic.c b/tic.c
--- a/tic.c	2024-05-12 03:21:53.102375590 +0000
+++ b/tic.c	2024-05-20 07:28:21.977135183 +0000
@@ -589,7 +589,8 @@
 	if (cdbw_output(db, fd, "NetBSD terminfo", cdbw_stable_seeder))
 		err(EXIT_FAILURE,
 		    "writing temporary database %s failed", tmp_dbname);
-	if (fchmod(fd, DEFFILEMODE))
+	mode_t m = umask(0077); (void)umask(m);
+	if (fchmod(fd, DEFFILEMODE & ~m))
 		err(EXIT_FAILURE, "fchmod failed");
 	if (close(fd))
 		err(EXIT_FAILURE,



Home | Main Index | Thread Index | Old Index