summaryrefslogtreecommitdiff
path: root/libbb/update_passwd.c
diff options
context:
space:
mode:
authorPaul Fox2007-11-08 01:12:38 +0000
committerPaul Fox2007-11-08 01:12:38 +0000
commit53bd4015aa7ec79b8f45edd30555ea7b7235d7ca (patch)
treec06946882377fd05d698e2abbeaf84fd4a5c9906 /libbb/update_passwd.c
parent459a2ba1efa9b84bf12c2f5b8a23fd89912b47ea (diff)
downloadbusybox-53bd4015aa7ec79b8f45edd30555ea7b7235d7ca.zip
busybox-53bd4015aa7ec79b8f45edd30555ea7b7235d7ca.tar.gz
follow symlinks to find the true passwd file before updating.
Diffstat (limited to 'libbb/update_passwd.c')
-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 388adf8..e99db40 100644
--- a/libbb/update_passwd.c
+++ b/libbb/update_passwd.c
@@ -52,6 +52,10 @@ int update_passwd(const char *filename, const char *username,
int cnt = 0;
int ret = -1; /* failure */
+ filename = xmalloc_readlink_follow(filename);
+ if (filename == NULL)
+ return -1;
+
check_selinux_update_passwd(username);
/* New passwd file, "/etc/passwd+" for now */
@@ -143,6 +147,7 @@ int update_passwd(const char *filename, const char *username,
free_mem:
free(fnamesfx);
- free((char*)username);
+ free((char *)filename);
+ free((char *)username);
return ret;
}