src/server/daemon/webserver.c

changeset 133
87b405d61f64
parent 129
fd324464f56f
child 146
a9591a91c004
equal deleted inserted replaced
132:e9afb5387007 133:87b405d61f64
124 log_ereport(LOG_FAILURE, "webserver_init: cannot get passwd data"); 124 log_ereport(LOG_FAILURE, "webserver_init: cannot get passwd data");
125 free(vars->Vuserpw); 125 free(vars->Vuserpw);
126 vars->Vuserpw = NULL; 126 vars->Vuserpw = NULL;
127 } 127 }
128 } 128 }
129 free(pwbuf);
130 if(!vars->Vuserpw) { 129 if(!vars->Vuserpw) {
131 log_ereport(LOG_WARN, "globalvars->Vuserpw is null"); 130 log_ereport(LOG_WARN, "globalvars->Vuserpw is null");
132 } 131 }
133 132
134 if(cfg->user.ptr) { 133 if(cfg->user.ptr) {
135 char *pwbuf = malloc(DEF_PWBUF);
136 vars->Vuserpw = malloc(sizeof(struct passwd)); 134 vars->Vuserpw = malloc(sizeof(struct passwd));
137 // open user database 135 // open user database
138 //setpwent(); 136 //setpwent();
139 if(!util_getpwnam(cfg->user.ptr, vars->Vuserpw, pwbuf, DEF_PWBUF)) { 137 if(!util_getpwnam(cfg->user.ptr, vars->Vuserpw, pwbuf, DEF_PWBUF)) {
140 log_ereport( 138 log_ereport(
142 "user %s does not exist!", 140 "user %s does not exist!",
143 cfg->user.ptr); 141 cfg->user.ptr);
144 free(vars->Vuserpw); 142 free(vars->Vuserpw);
145 vars->Vuserpw = NULL; 143 vars->Vuserpw = NULL;
146 } 144 }
147 free(pwbuf);
148 //endpwent(); // TODO: close or not? 145 //endpwent(); // TODO: close or not?
149 } 146 }
147 free(pwbuf);
150 148
151 // change uid 149 // change uid
152 if(vars->Vuserpw && ws_uid == 0) { 150 if(vars->Vuserpw && ws_uid == 0) {
153 // a webserver user is set and we are root 151 // a webserver user is set and we are root
154 152

mercurial