[xiph-cvs] cvs commit: icecast/src main.c
Michael Smith
msmith at xiph.org
Mon May 20 17:05:32 PDT 2002
msmith 02/05/20 17:05:31
Modified: src main.c
Log:
Fix potential problem which would occur if <changeuser> was set, but had
no <user> or no <group> element within it.
Revision Changes Path
1.7 +28 -17 icecast/src/main.c
Index: main.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/main.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- main.c 2002/05/20 13:25:31 1.6
+++ main.c 2002/05/21 00:05:31 1.7
@@ -92,11 +92,18 @@
char fn_access[FILENAME_MAX];
ice_config_t *config = config_get_config();
- snprintf(fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->error_log);
- snprintf(fn_access, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->access_log);
-
- errorlog = log_open(fn_error);
- accesslog = log_open(fn_access);
+ if(strcmp(config->error_log, "-")) {
+ snprintf(fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->error_log);
+ errorlog = log_open(fn_error);
+ } else {
+ errorlog = log_open_file(stderr);
+ }
+ if(strcmp(config->access_log, "-")) {
+ snprintf(fn_access, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->access_log);
+ accesslog = log_open(fn_access);
+ } else {
+ accesslog = log_open_file(stderr);
+ }
log_set_level(errorlog, 4);
log_set_level(accesslog, 4);
@@ -176,17 +183,21 @@
if(conf->chuid)
{
- user = getpwnam(conf->user);
- group = getgrnam(conf->group);
+ if(conf->user) {
+ user = getpwnam(conf->user);
+ if(user)
+ uid = user->pw_uid;
+ else
+ fprintf(stderr, "Couldn't find user \"%s\" in password file\n", conf->user);
+ }
+ if(conf->group) {
+ group = getgrnam(conf->group);
- if(user)
- uid = user->pw_uid;
- else
- fprintf(stderr, "Couldn't find user \"%s\" in password file\n", conf->user);
- if(group)
- gid = group->gr_gid;
- else
- fprintf(stderr, "Couldn't find group \"%s\" in groups file\n", conf->group);
+ if(group)
+ gid = group->gr_gid;
+ else
+ fprintf(stderr, "Couldn't find group \"%s\" in groups file\n", conf->group);
+ }
}
#endif
@@ -220,14 +231,14 @@
if(gid != -1) {
if(!setgid(gid))
- fprintf(stdout, "Changed groupid to %i.\n", group->gr_gid);
+ fprintf(stdout, "Changed groupid to %i.\n", gid);
else
fprintf(stdout, "Error changing groupid: %s.\n", strerror(errno));
}
if(uid != -1) {
if(!setuid(uid))
- fprintf(stdout, "Changed userid to %i.\n", user->pw_uid);
+ fprintf(stdout, "Changed userid to %i.\n", uid);
else
fprintf(stdout, "Error changing userid: %s.\n", strerror(errno));
}
<p><p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list