--On 2006-12-04 4:44 PM -0800 Mark Crispin <[EMAIL PROTECTED]> wrote:
To create a mix-format INBOX, using the command
        mailutil create #driver.mix/INBOX
while setuid'd to the desired user.

Mark, that reminds me...

I haven't tried this with imap-2006*, but in imap-2004g and earlier, this
didn't work for me.  I wanted to use "sudo -u user mailutil ...", but
that doesn't work because my_username_full() in src/osdep/unix/env_unix.c
used getlogin() to get the username, then used that username to get the uid,
rather than just using getpwuid(geteuid()).

I patched this function locally so that we could use mailutil through sudo.
(I also just use pw->pw_dir rather than checking $HOME's status.)

Is there some other way that you recommend using mailutil while setuid'd to
the desired user?  And is there some reason that my much simpler code is
likely to break that I haven't thought of, that justifies the more
complicated approach in the distribution?

***************
*** 752,771 ****
 char *myusername_full (unsigned long *flags)
 {
   struct passwd *pw;
-   struct stat sbuf;
-   char *s;
   unsigned long euid;
   char *ret = UNLOGGEDUSER;
                               /* no user name yet and not root? */
   if (!myUserName && (euid = geteuid ())) {
! /* yes, look up getlogin() user name or EUID */
!     if (((s = (char *) getlogin ()) && *s && (strlen (s) < NETMAXUSER) &&
!        (pw = getpwnam (s)) && (pw->pw_uid == euid)) ||
!       (pw = getpwuid (euid)))
!       env_init (pw->pw_name,
!               ((s = getenv ("HOME")) && *s && (strlen (s) < NETMAXMBX) &&
!                !stat (s,&sbuf) && ((sbuf.st_mode & S_IFMT) == S_IFDIR)) ?
!               s : pw->pw_dir);
     else fatal ("Unable to look up user name");
   }
   if (myUserName) {           /* logged in? */
--- 716,728 ----
 char *myusername_full (unsigned long *flags)
 {
   struct passwd *pw;
   unsigned long euid;
   char *ret = UNLOGGEDUSER;
                               /* no user name yet and not root? */
   if (!myUserName && (euid = geteuid ())) {
!                               /* yes, look up EUID */
!     if (pw = getpwuid (euid))
!       env_init (pw->pw_name, pw->pw_dir);
     else fatal ("Unable to look up user name");
   }
   if (myUserName) {           /* logged in? */

Thanks,

Mark
--
Mark Sirota, Associate Director, Network Engineering and Services
University of Pennsylvania, Information Systems and Computing
[EMAIL PROTECTED], +1 215 573 7214
_______________________________________________
Imap-uw mailing list
[email protected]
https://mailman1.u.washington.edu/mailman/listinfo/imap-uw

Reply via email to