git-svn: trunk@2952
Tomasz Kojm authored on 2007/03/20 05:36:17... | ... |
@@ -86,7 +86,7 @@ int main(int argc, char **argv) |
86 | 86 |
{ |
87 | 87 |
struct cfgstruct *copt; |
88 | 88 |
const struct cfgstruct *cpt; |
89 |
- struct passwd *user; |
|
89 |
+ struct passwd *user = NULL; |
|
90 | 90 |
time_t currtime; |
91 | 91 |
struct cl_engine *engine = NULL; |
92 | 92 |
const char *dbdir, *cfgfile; |
... | ... |
@@ -165,8 +165,6 @@ int main(int argc, char **argv) |
165 | 165 |
if(geteuid() == 0 && (cpt = cfgopt(copt, "User"))->enabled) { |
166 | 166 |
if((user = getpwnam(cpt->strarg)) == NULL) { |
167 | 167 |
fprintf(stderr, "ERROR: Can't get information about user %s.\n", cpt->strarg); |
168 |
- logg("!Can't get information about user %s.\n", cpt->strarg); |
|
169 |
- logg_close(); |
|
170 | 168 |
freecfg(copt); |
171 | 169 |
return 1; |
172 | 170 |
} |
... | ... |
@@ -175,20 +173,16 @@ int main(int argc, char **argv) |
175 | 175 |
#ifdef HAVE_INITGROUPS |
176 | 176 |
if(initgroups(cpt->strarg, user->pw_gid)) { |
177 | 177 |
fprintf(stderr, "ERROR: initgroups() failed.\n"); |
178 |
- logg("!initgroups() failed.\n"); |
|
179 |
- logg_close(); |
|
180 | 178 |
freecfg(copt); |
181 | 179 |
return 1; |
182 | 180 |
} |
183 | 181 |
#else |
184 |
- logg("AllowSupplementaryGroups: initgroups() not supported.\n"); |
|
182 |
+ mprintf("AllowSupplementaryGroups: initgroups() not supported.\n"); |
|
185 | 183 |
#endif |
186 | 184 |
} else { |
187 | 185 |
#ifdef HAVE_SETGROUPS |
188 | 186 |
if(setgroups(1, &user->pw_gid)) { |
189 | 187 |
fprintf(stderr, "ERROR: setgroups() failed.\n"); |
190 |
- logg("!setgroups() failed.\n"); |
|
191 |
- logg_close(); |
|
192 | 188 |
freecfg(copt); |
193 | 189 |
return 1; |
194 | 190 |
} |
... | ... |
@@ -197,22 +191,15 @@ int main(int argc, char **argv) |
197 | 197 |
|
198 | 198 |
if(setgid(user->pw_gid)) { |
199 | 199 |
fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid); |
200 |
- logg("!setgid(%d) failed.\n", (int) user->pw_gid); |
|
201 |
- logg_close(); |
|
202 | 200 |
freecfg(copt); |
203 | 201 |
return 1; |
204 | 202 |
} |
205 | 203 |
|
206 |
- |
|
207 | 204 |
if(setuid(user->pw_uid)) { |
208 | 205 |
fprintf(stderr, "ERROR: setuid(%d) failed.\n", (int) user->pw_uid); |
209 |
- logg("!setuid(%d) failed.\n", (int) user->pw_uid); |
|
210 |
- logg_close(); |
|
211 | 206 |
freecfg(copt); |
212 | 207 |
return 1; |
213 | 208 |
} |
214 |
- |
|
215 |
- logg("Running as user %s (UID %d, GID %d)\n", user->pw_name, user->pw_uid, user->pw_gid); |
|
216 | 209 |
} |
217 | 210 |
#endif |
218 | 211 |
|
... | ... |
@@ -299,6 +286,9 @@ int main(int argc, char **argv) |
299 | 299 |
|
300 | 300 |
logg("clamd daemon "VERSION" (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")\n"); |
301 | 301 |
|
302 |
+ if(user) |
|
303 |
+ logg("Running as user %s (UID %u, GID %u)\n", user->pw_name, user->pw_uid, user->pw_gid); |
|
304 |
+ |
|
302 | 305 |
if(logg_size) |
303 | 306 |
logg("Log file size limited to %d bytes.\n", logg_size); |
304 | 307 |
else |