OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Postfix Archives: Re: [PATCH][FIX][snapshot-19991123] postconf

Re: [PATCH][FIX][snapshot-19991123] postconf -e is sensitive to umask/group settings


Wietse Venema (wietseporcupine.org)
Thu, 25 Nov 1999 22:12:08 -0500 (EST)


Rather than calling chmod it would be a lot simpler to have a
umask(022) call at the start of the postconf program.

However, I have a comment. If you have a 077 super-user umask you
will have broken file permissions mor often. I recommend that you
use 022 instead for root. You can still use 077 for yourself.

        Wietse

Matthias Andree:
> Hi, Wietse,
>
> while I appreciate the new -e option of postconf, it has a bug which can
> end up breaking the entire system:
>
> Procedure to verify (assumed that $config_directory == /etc/postfix):
>
> su
> umask 077
> ls -l /etc/postfix/main.cf
> postconf -e x_for_demonstration_only=true
> ls -l /etc/postfix/main.cf
>
> After that, $sendmail_path will break deliveries by unprivileged users
> since it cannot read the main.cf any more. Besides that, it may happen
> that postconf is not invoked with group root, which would leave it
> belonging to another group (this is rather cosmetic).
>
> Below is a patch which alleviates these problems. You may of course
> choose to omit the chown() lines if you find them inappropriate.
>
>
>
> diff -cr snapshot-19991123/HISTORY snapshot-19991123-ma1/HISTORY
> *** snapshot-19991123/HISTORY Tue Nov 23 14:00:55 1999
> --- snapshot-19991123-ma1/HISTORY Fri Nov 26 02:41:30 1999
> ***************
> *** 3291,3293 ****
> --- 3291,3300 ----
> 19991122
>
> Bugfix: missing absolute path in INSTALL.sh broke fresh install.
> +
> + 19991126
> +
> + Bugfix: postconf -e was sensitive to umask and could thus leave
> + main.cf with 0600 after edit, breaking the entire system.
> + main.cf is now forced to mode 0644 after edit (patch by Matthias
> + Andree). File: postconf/postconf.c.
> diff -cr snapshot-19991123/postconf/postconf.c snapshot-19991123-ma1/postconf/postconf.c
> *** snapshot-19991123/postconf/postconf.c Fri Nov 19 03:29:27 1999
> --- snapshot-19991123-ma1/postconf/postconf.c Fri Nov 26 02:37:44 1999
> ***************
> *** 349,359 ****
> --- 349,364 ----
>
> /*
> * When all is well, rename the temp file to the original one.
> + * Set sane permissions and ownership independently of umask setting.
> */
> if (vstream_fclose(src))
> msg_fatal("read %s: %m", path);
> if (vstream_fclose(dst))
> msg_fatal("write %s: %m", temp);
> + if (chmod(temp, 0644))
> + msg_fatal("chmod %s to 0644: %m", temp);
> + if (chown(temp, 0, 0))
> + msg_fatal("chown %s to root.root: %m", temp);
> if (rename(temp, path) < 0)
> msg_fatal("rename %s to %s: %m", temp, path);
>
>
>
> --
> Matthias Andree
>
> Hi! I'm the infamous .signature virus!
> Copy me into your ~/.signature to help me spread!
>
>
>



This archive was generated by hypermail 2.0b3 on Thu Nov 25 1999 - 21:13:32 CST