aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-19 04:37:19 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-19 04:37:19 +0200
commit3d0805e9e7c45e6c0f9fb5e587d8b4a5a5f3c74c (patch)
treed950f4ca13fcd5993a34daf36b61f719e226497a
parent526d85831e7480b9c7a3673d8dd356a438e6dd74 (diff)
downloadbusybox-w32-3d0805e9e7c45e6c0f9fb5e587d8b4a5a5f3c74c.tar.gz
busybox-w32-3d0805e9e7c45e6c0f9fb5e587d8b4a5a5f3c74c.tar.bz2
busybox-w32-3d0805e9e7c45e6c0f9fb5e587d8b4a5a5f3c74c.zip
libbb: make parse_chown_usergroup_or_die() set unspecified uid/gid to -1
function old new delta parse_chown_usergroup_or_die 102 115 +13 chown_main 190 175 -15 start_stop_daemon_main 1043 1027 -16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 13/-31) Total: -18 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/chown.c4
-rw-r--r--debianutils/start_stop_daemon.c8
-rw-r--r--libpwdgrp/uidgid_get.c2
3 files changed, 6 insertions, 8 deletions
diff --git a/coreutils/chown.c b/coreutils/chown.c
index eaa1ee2a3..247aa3bf1 100644
--- a/coreutils/chown.c
+++ b/coreutils/chown.c
@@ -112,10 +112,6 @@ int chown_main(int argc UNUSED_PARAM, char **argv)
112 int opt, flags; 112 int opt, flags;
113 struct param_t param; 113 struct param_t param;
114 114
115 /* Just -1 might not work: uid_t may be unsigned long */
116 param.ugid.uid = -1L;
117 param.ugid.gid = -1L;
118
119#if ENABLE_FEATURE_CHOWN_LONG_OPTIONS 115#if ENABLE_FEATURE_CHOWN_LONG_OPTIONS
120 applet_long_options = chown_longopts; 116 applet_long_options = chown_longopts;
121#endif 117#endif
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index 42f1943dd..d7c730f45 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -539,15 +539,15 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
539 write_pidfile(pidfile); 539 write_pidfile(pidfile);
540 } 540 }
541 if (opt & OPT_c) { 541 if (opt & OPT_c) {
542 struct bb_uidgid_t ugid = { -1, -1 }; 542 struct bb_uidgid_t ugid;
543 parse_chown_usergroup_or_die(&ugid, chuid); 543 parse_chown_usergroup_or_die(&ugid, chuid);
544 if (ugid.uid != (uid_t) -1) { 544 if (ugid.uid != (uid_t) -1L) {
545 struct passwd *pw = xgetpwuid(ugid.uid); 545 struct passwd *pw = xgetpwuid(ugid.uid);
546 if (ugid.gid != (gid_t) -1) 546 if (ugid.gid != (gid_t) -1L)
547 pw->pw_gid = ugid.gid; 547 pw->pw_gid = ugid.gid;
548 /* initgroups, setgid, setuid: */ 548 /* initgroups, setgid, setuid: */
549 change_identity(pw); 549 change_identity(pw);
550 } else if (ugid.gid != (gid_t) -1) { 550 } else if (ugid.gid != (gid_t) -1L) {
551 xsetgid(ugid.gid); 551 xsetgid(ugid.gid);
552 setgroups(1, &ugid.gid); 552 setgroups(1, &ugid.gid);
553 } 553 }
diff --git a/libpwdgrp/uidgid_get.c b/libpwdgrp/uidgid_get.c
index eeb65191f..1199f23f9 100644
--- a/libpwdgrp/uidgid_get.c
+++ b/libpwdgrp/uidgid_get.c
@@ -90,6 +90,8 @@ void FAST_FUNC parse_chown_usergroup_or_die(struct bb_uidgid_t *u, char *user_gr
90{ 90{
91 char *group; 91 char *group;
92 92
93 u->uid = u->gid = (gid_t)-1L;
94
93 /* Check if there is a group name */ 95 /* Check if there is a group name */
94 group = strchr(user_group, '.'); /* deprecated? */ 96 group = strchr(user_group, '.'); /* deprecated? */
95 if (!group) 97 if (!group)