Gentoo Archives: gentoo-commits

From: "Robin H. Johnson (robbat2)" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-admin/cronolog/files: cronolog-1.6.2-umask.patch
Date: Tue, 26 Jan 2010 09:25:24
Message-Id: E1NZhfj-00070M-Na@stork.gentoo.org
1 robbat2 10/01/26 09:25:19
2
3 Added: cronolog-1.6.2-umask.patch
4 Log:
5 Add umask support to cronolog. Patch by Mike Doty <kingtaco@g.o>, confirmed by myself.
6 (Portage version: 2.2_rc61/cvs/Linux x86_64)
7
8 Revision Changes Path
9 1.1 app-admin/cronolog/files/cronolog-1.6.2-umask.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/cronolog/files/cronolog-1.6.2-umask.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/cronolog/files/cronolog-1.6.2-umask.patch?rev=1.1&content-type=text/plain
13
14 Index: cronolog-1.6.2-umask.patch
15 ===================================================================
16 Add umask support to cronolog.
17
18 Patch-by: Mike Doty <kingtaco@g.o>
19 Signed-off-By: Robin H. Johnson <robbat2@g.o>
20
21 --- src/cronolog.c.orig 2010-01-22 16:49:41.000000000 -0800
22 +++ src/cronolog.c 2010-01-22 17:31:50.000000000 -0800
23 @@ -106,7 +106,8 @@
24
25 #ifndef _WIN32
26 #define SETUGID_USAGE " -u USER, --set-uid=USER change to USER before doing anything (name or UID)\n" \
27 - " -g GROUP, --set-gid=GROUP change to GROUP before doing anything (name or GID)\n"
28 + " -g GROUP, --set-gid=GROUP change to GROUP before doing anything (name or GID)\n" \
29 + " -U OCTAL, --umask=OCTAL sets umask of file/directory creation\n"
30 #else
31 #define SETUGID_USAGE ""
32 #endif
33 @@ -134,7 +135,7 @@
34 /* Definition of the short and long program options */
35
36 #ifndef _WIN32
37 -char *short_options = "ad:eop:s:z:H:P:S:l:hVx:u:g:";
38 +char *short_options = "ad:eop:s:z:H:P:S:l:hVx:u:g:U:";
39 #else
40 char *short_options = "ad:eop:s:z:H:P:S:l:hVx:";
41 #endif
42 @@ -157,10 +158,16 @@
43 { "once-only", no_argument, NULL, 'o' },
44 { "help", no_argument, NULL, 'h' },
45 { "version", no_argument, NULL, 'V' },
46 + { "umask", required_argument, NULL, 'U' },
47 { NULL, 0, NULL, 0 }
48 };
49 #endif
50
51 +#ifndef _WIN32
52 +static mode_t saved_umask = 0;
53 +static mode_t new_umask = 0;
54 +#endif
55 +
56 /* Main function.
57 */
58 int
59 @@ -193,6 +200,11 @@
60 int log_fd = -1;
61
62 #ifndef _WIN32
63 + new_umask=umask(0);
64 + umask(new_umask);
65 +#endif
66 +
67 +#ifndef _WIN32
68 while ((ch = getopt_long(argc, argv, short_options, long_options, NULL)) != EOF)
69 #else
70 while ((ch = getopt(argc, argv, short_options)) != EOF)
71 @@ -267,6 +279,9 @@
72 new_gid = parse_gid(optarg, argv[0]);
73 change_gid = 1;
74 break;
75 + case 'U':
76 + new_umask = (mode_t)strtol(optarg, NULL, 8);
77 + break;
78 #endif
79 case 'o':
80 periodicity = ONCE_ONLY;
81 @@ -443,6 +458,9 @@
82 timestamp(*pnext_period), *pnext_period,
83 *pnext_period - time_now));
84
85 +#ifndef _WIN32
86 + saved_umask=umask(new_umask);
87 +#endif
88 log_fd = open(pfilename, O_WRONLY|O_CREAT|O_APPEND|O_LARGEFILE, FILE_MODE);
89
90 #ifndef DONT_CREATE_SUBDIRS
91 @@ -459,6 +477,10 @@
92 exit(2);
93 }
94
95 +#ifndef _WIN32
96 + umask(saved_umask);
97 +#endif
98 +
99 if (linkname)
100 {
101 create_link(pfilename, linkname, linktype, prevlinkname);