Mercurial > dovecot > core-2.2
comparison src/util/rawlog.c @ 5447:04404fd54cf6 HEAD
Fixed to work with chrooting
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 28 Mar 2007 23:07:38 +0300 |
parents | 784dc7224718 |
children | 6c0bfc35af03 |
comparison
equal
deleted
inserted
replaced
5446:ce1e1fab1e1d | 5447:04404fd54cf6 |
---|---|
265 return proxy; | 265 return proxy; |
266 } | 266 } |
267 | 267 |
268 static void rawlog_open(enum rawlog_flags flags) | 268 static void rawlog_open(enum rawlog_flags flags) |
269 { | 269 { |
270 const char *home, *path; | 270 const char *chroot, *home, *path; |
271 struct stat st; | 271 struct stat st; |
272 int sfd[2]; | 272 int sfd[2]; |
273 pid_t pid; | 273 pid_t pid; |
274 | 274 |
275 chroot = getenv("RESTRICT_CHROOT"); | |
275 home = getenv("HOME"); | 276 home = getenv("HOME"); |
276 if (home == NULL) | 277 if (chroot != NULL) |
278 home = t_strconcat(chroot, home, NULL); | |
279 else if (home == NULL) | |
277 home = "."; | 280 home = "."; |
278 | 281 |
279 /* see if we want rawlog */ | 282 /* see if we want rawlog */ |
280 path = t_strconcat(home, "/dovecot.rawlog", NULL); | 283 path = t_strconcat(home, "/dovecot.rawlog", NULL); |
281 if (lstat(path, &st) < 0) { | 284 if (lstat(path, &st) < 0) { |
283 i_warning("lstat() failed for %s: %m", path); | 286 i_warning("lstat() failed for %s: %m", path); |
284 return; | 287 return; |
285 } | 288 } |
286 if (!S_ISDIR(st.st_mode)) | 289 if (!S_ISDIR(st.st_mode)) |
287 return; | 290 return; |
291 | |
292 if (chroot != NULL) { | |
293 /* we'll chroot soon. skip over the chroot in the path. */ | |
294 path += strlen(chroot); | |
295 } | |
288 | 296 |
289 if (socketpair(AF_UNIX, SOCK_STREAM, 0, sfd) < 0) | 297 if (socketpair(AF_UNIX, SOCK_STREAM, 0, sfd) < 0) |
290 i_fatal("socketpair() failed: %m"); | 298 i_fatal("socketpair() failed: %m"); |
291 | 299 |
292 pid = fork(); | 300 pid = fork(); |