summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2008-11-07 04:11:03 +0000
committerRoger Dingledine <arma@torproject.org>2008-11-07 04:11:03 +0000
commit7c657925000286725b0cb080c8b920383e493d0e (patch)
treed402c31a7d973a15d5fd4ce391d00310a35cb418 /src/common
parentd27337bf1775a84c8b3061ecd39920f1b16dd2bd (diff)
downloadtor-7c657925000286725b0cb080c8b920383e493d0e.tar.gz
tor-7c657925000286725b0cb080c8b920383e493d0e.zip
remove more redundant code from r17200
svn:r17203
Diffstat (limited to 'src/common')
-rw-r--r--src/common/compat.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index 54c4ff0430..ecbae6ab0b 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -1016,7 +1016,7 @@ log_credential_status(void)
return 0;
}
-/** Call setuid and setgid to run as <b>user</b> and only switch to their
+/** Call setuid and setgid to run as <b>user</b> and switch to their
* primary group. Return 0 on success. On failure, log and return -1.
*/
int
@@ -1030,11 +1030,9 @@ switch_id(const char *user)
tor_assert(user);
/* Log the initial credential state */
- if (user) {
- if (log_credential_status()) {
- return -1;
- }
- }
+ if (log_credential_status())
+ return -1;
+
log_fn(CREDENTIAL_LOG_LEVEL, LD_GENERAL, "Changing user and groups");
/* Get old UID/GID to check if we changed correctly */
@@ -1042,15 +1040,9 @@ switch_id(const char *user)
old_gid = getgid();
/* Lookup the user and group information, if we have a problem, bail out. */
- if (user) {
- pw = getpwnam(user);
- if (pw == NULL) {
- log_warn(LD_CONFIG, "Error setting configured user: %s not found", user);
- return -1;
- }
- } else {
- /* We have no user supplied and so we'll bail out. */
- log_warn(LD_CONFIG, "Error setting configured user: No user supplied.");
+ pw = getpwnam(user);
+ if (pw == NULL) {
+ log_warn(LD_CONFIG, "Error setting configured user: %s not found", user);
return -1;
}
@@ -1121,10 +1113,8 @@ switch_id(const char *user)
#endif
/* Check what really happened */
- if (user) {
- if (log_credential_status()) {
- return -1;
- }
+ if (log_credential_status()) {
+ return -1;
}
return 0;