aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Fox <pgf@brightstareng.com>2007-11-08 01:12:38 +0000
committerPaul Fox <pgf@brightstareng.com>2007-11-08 01:12:38 +0000
commit53bd4015aa7ec79b8f45edd30555ea7b7235d7ca (patch)
treec06946882377fd05d698e2abbeaf84fd4a5c9906
parent459a2ba1efa9b84bf12c2f5b8a23fd89912b47ea (diff)
downloadbusybox-w32-53bd4015aa7ec79b8f45edd30555ea7b7235d7ca.tar.gz
busybox-w32-53bd4015aa7ec79b8f45edd30555ea7b7235d7ca.tar.bz2
busybox-w32-53bd4015aa7ec79b8f45edd30555ea7b7235d7ca.zip
follow symlinks to find the true passwd file before updating.
-rw-r--r--libbb/update_passwd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libbb/update_passwd.c b/libbb/update_passwd.c
index 388adf81f..e99db40c0 100644
--- a/libbb/update_passwd.c
+++ b/libbb/update_passwd.c
@@ -52,6 +52,10 @@ int update_passwd(const char *filename, const char *username,
52 int cnt = 0; 52 int cnt = 0;
53 int ret = -1; /* failure */ 53 int ret = -1; /* failure */
54 54
55 filename = xmalloc_readlink_follow(filename);
56 if (filename == NULL)
57 return -1;
58
55 check_selinux_update_passwd(username); 59 check_selinux_update_passwd(username);
56 60
57 /* New passwd file, "/etc/passwd+" for now */ 61 /* New passwd file, "/etc/passwd+" for now */
@@ -143,6 +147,7 @@ int update_passwd(const char *filename, const char *username,
143 147
144 free_mem: 148 free_mem:
145 free(fnamesfx); 149 free(fnamesfx);
146 free((char*)username); 150 free((char *)filename);
151 free((char *)username);
147 return ret; 152 return ret;
148} 153}