summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-09-28 16:40:02 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-09-28 16:40:02 +0000
commit4a81fe4173bf5029058253cf0be194c23a5ad369 (patch)
tree0806d2c3d6df92784c407221d862b9956c9ea115 /miscutils
parent3e7eca97b987b351c6f68308c6e0c421541f10c8 (diff)
downloadbusybox-w32-1_11_3.tar.gz
busybox-w32-1_11_3.tar.bz2
busybox-w32-1_11_3.zip
apply post-1.11.2 fixes, bump version to 1.11.31_11_3
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/crontab.c19
-rw-r--r--miscutils/taskset.c3
2 files changed, 12 insertions, 10 deletions
diff --git a/miscutils/crontab.c b/miscutils/crontab.c
index dc3179dac..38933cf4a 100644
--- a/miscutils/crontab.c
+++ b/miscutils/crontab.c
@@ -93,6 +93,7 @@ int crontab_main(int argc ATTRIBUTE_UNUSED, char **argv)
93 char *new_fname; 93 char *new_fname;
94 char *user_name; /* -u USER */ 94 char *user_name; /* -u USER */
95 int fd; 95 int fd;
96 int src_fd;
96 int opt_ler; 97 int opt_ler;
97 98
98 /* file [opts] Replace crontab from file 99 /* file [opts] Replace crontab from file
@@ -144,15 +145,15 @@ int crontab_main(int argc ATTRIBUTE_UNUSED, char **argv)
144 bb_show_usage(); 145 bb_show_usage();
145 146
146 /* Read replacement file under user's UID/GID/group vector */ 147 /* Read replacement file under user's UID/GID/group vector */
148 src_fd = STDIN_FILENO;
147 if (!opt_ler) { /* Replace? */ 149 if (!opt_ler) { /* Replace? */
148 if (!argv[0]) 150 if (!argv[0])
149 bb_show_usage(); 151 bb_show_usage();
150 if (NOT_LONE_DASH(argv[0])) { 152 if (NOT_LONE_DASH(argv[0])) {
151 fd = open_as_user(pas, argv[0]); 153 src_fd = open_as_user(pas, argv[0]);
152 if (fd < 0) 154 if (src_fd < 0)
153 bb_error_msg_and_die("user %s cannot read %s", 155 bb_error_msg_and_die("user %s cannot read %s",
154 pas->pw_name, argv[0]); 156 pas->pw_name, argv[0]);
155 xmove_fd(fd, STDIN_FILENO);
156 } 157 }
157 } 158 }
158 159
@@ -180,23 +181,23 @@ int crontab_main(int argc ATTRIBUTE_UNUSED, char **argv)
180 tmp_fname = xasprintf("%s.%u", crontab_dir, (unsigned)getpid()); 181 tmp_fname = xasprintf("%s.%u", crontab_dir, (unsigned)getpid());
181 /* No O_EXCL: we don't want to be stuck if earlier crontabs 182 /* No O_EXCL: we don't want to be stuck if earlier crontabs
182 * were killed, leaving stale temp file behind */ 183 * were killed, leaving stale temp file behind */
183 fd = xopen3(tmp_fname, O_RDWR|O_CREAT|O_TRUNC, 0600); 184 src_fd = xopen3(tmp_fname, O_RDWR|O_CREAT|O_TRUNC, 0600);
184 xmove_fd(fd, STDIN_FILENO); 185 fchown(src_fd, pas->pw_uid, pas->pw_gid);
185 fchown(STDIN_FILENO, pas->pw_uid, pas->pw_gid);
186 fd = open(pas->pw_name, O_RDONLY); 186 fd = open(pas->pw_name, O_RDONLY);
187 if (fd >= 0) { 187 if (fd >= 0) {
188 bb_copyfd_eof(fd, STDIN_FILENO); 188 bb_copyfd_eof(fd, src_fd);
189 close(fd); 189 close(fd);
190 xlseek(src_fd, 0, SEEK_SET);
190 } 191 }
192 close_on_exec_on(src_fd); /* don't want editor to see this fd */
191 edit_file(pas, tmp_fname); 193 edit_file(pas, tmp_fname);
192 xlseek(STDIN_FILENO, 0, SEEK_SET);
193 /* fall through */ 194 /* fall through */
194 195
195 case 0: /* Replace (no -l, -e, or -r were given) */ 196 case 0: /* Replace (no -l, -e, or -r were given) */
196 new_fname = xasprintf("%s.new", pas->pw_name); 197 new_fname = xasprintf("%s.new", pas->pw_name);
197 fd = open(new_fname, O_WRONLY|O_CREAT|O_TRUNC|O_APPEND, 0600); 198 fd = open(new_fname, O_WRONLY|O_CREAT|O_TRUNC|O_APPEND, 0600);
198 if (fd >= 0) { 199 if (fd >= 0) {
199 bb_copyfd_eof(STDIN_FILENO, fd); 200 bb_copyfd_eof(src_fd, fd);
200 close(fd); 201 close(fd);
201 xrename(new_fname, pas->pw_name); 202 xrename(new_fname, pas->pw_name);
202 } else { 203 } else {
diff --git a/miscutils/taskset.c b/miscutils/taskset.c
index 708abd9f2..973f94ac3 100644
--- a/miscutils/taskset.c
+++ b/miscutils/taskset.c
@@ -35,7 +35,8 @@ static char *__from_cpuset(cpu_set_t *mask)
35#define TASKSET_PRINTF_MASK "%x" 35#define TASKSET_PRINTF_MASK "%x"
36/* (void*) cast is for battling gcc: */ 36/* (void*) cast is for battling gcc: */
37/* "dereferencing type-punned pointer will break strict-aliasing rules" */ 37/* "dereferencing type-punned pointer will break strict-aliasing rules" */
38#define from_cpuset(mask) (*(unsigned*)(void*)&(mask)) 38#define from_cpuset(mask) ({ void *__vp = &(mask); *(unsigned*)__vp; })
39/* gcc 4.3.0 still complains: #define from_cpuset(mask) (*(unsigned*)(void*)&(mask)) */
39#endif 40#endif
40 41
41 42