summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-19 02:37:19 (GMT)
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-19 02:37:19 (GMT)
commit3d0805e9e7c45e6c0f9fb5e587d8b4a5a5f3c74c (patch)
treed950f4ca13fcd5993a34daf36b61f719e226497a
parent526d85831e7480b9c7a3673d8dd356a438e6dd74 (diff)
downloadbusybox-3d0805e9e7c45e6c0f9fb5e587d8b4a5a5f3c74c.zip
busybox-3d0805e9e7c45e6c0f9fb5e587d8b4a5a5f3c74c.tar.gz
busybox-3d0805e9e7c45e6c0f9fb5e587d8b4a5a5f3c74c.tar.bz2
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 eaa1ee2..247aa3b 100644
--- a/coreutils/chown.c
+++ b/coreutils/chown.c
@@ -112,10 +112,6 @@ int chown_main(int argc UNUSED_PARAM, char **argv)
int opt, flags;
struct param_t param;
- /* Just -1 might not work: uid_t may be unsigned long */
- param.ugid.uid = -1L;
- param.ugid.gid = -1L;
-
#if ENABLE_FEATURE_CHOWN_LONG_OPTIONS
applet_long_options = chown_longopts;
#endif
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index 42f1943..d7c730f 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)
write_pidfile(pidfile);
}
if (opt & OPT_c) {
- struct bb_uidgid_t ugid = { -1, -1 };
+ struct bb_uidgid_t ugid;
parse_chown_usergroup_or_die(&ugid, chuid);
- if (ugid.uid != (uid_t) -1) {
+ if (ugid.uid != (uid_t) -1L) {
struct passwd *pw = xgetpwuid(ugid.uid);
- if (ugid.gid != (gid_t) -1)
+ if (ugid.gid != (gid_t) -1L)
pw->pw_gid = ugid.gid;
/* initgroups, setgid, setuid: */
change_identity(pw);
- } else if (ugid.gid != (gid_t) -1) {
+ } else if (ugid.gid != (gid_t) -1L) {
xsetgid(ugid.gid);
setgroups(1, &ugid.gid);
}
diff --git a/libpwdgrp/uidgid_get.c b/libpwdgrp/uidgid_get.c
index eeb6519..1199f23 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
{
char *group;
+ u->uid = u->gid = (gid_t)-1L;
+
/* Check if there is a group name */
group = strchr(user_group, '.'); /* deprecated? */
if (!group)