From: Timo Sirainen Date: Tue, 20 Oct 2009 23:23:34 +0000 (-0400) Subject: master: Drop trailing '/' from services' chroot directory. X-Git-Tag: 2.0.alpha2~50 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e1f866daa1bd1a5cd7516f3b19c6f197bcf6cc8a;p=thirdparty%2Fdovecot%2Fcore.git master: Drop trailing '/' from services' chroot directory. --HG-- branch : HEAD --- diff --git a/src/master/service-process.c b/src/master/service-process.c index aa4ce00118..488db44b28 100644 --- a/src/master/service-process.c +++ b/src/master/service-process.c @@ -134,6 +134,7 @@ drop_privileges(struct service *service) { struct restrict_access_settings rset; bool disallow_root; + unsigned int len; if (service->vsz_limit != 0) restrict_process_size(service->vsz_limit, -1U); @@ -144,6 +145,12 @@ drop_privileges(struct service *service) rset.privileged_gid = service->privileged_gid; rset.chroot_dir = *service->set->chroot == '\0' ? NULL : service->set->chroot; + if (rset.chroot_dir != NULL) { + /* drop trailing / if it exists */ + len = strlen(rset.chroot_dir); + if (rset.chroot_dir[len-1] == '/') + rset.chroot_dir = t_strndup(rset.chroot_dir, len-1); + } rset.extra_groups = service->extra_gids; if (service->set->drop_priv_before_exec) {