--- imap/src/osdep/unix/env_unix.c.orig Mon Jan 12 05:12:25 2015 +++ imap/src/osdep/unix/env_unix.c Mon Aug 24 17:06:26 2020 @@ -644,11 +644,11 @@ static struct passwd *pwuser (unsigned char *user) { unsigned char *s; - struct passwd *pw = getpwnam (user); + struct passwd *pw = getpwnam_shadow (user); if (!pw) { /* failed, see if any uppercase characters */ for (s = user; *s && ((*s < 'A') || (*s > 'Z')); s++); if (*s) { /* yes, try all lowercase form */ - pw = getpwnam (s = lcase (cpystr (user))); + pw = getpwnam_shadow (s = lcase (cpystr (user))); fs_give ((void **) &s); } } @@ -967,15 +967,12 @@ static char *mymailboxdir () { char *home = myhomedir (); - /* initialize if first time */ - if (!myMailboxDir && myHomeDir) { if (mailsubdir) { char tmp[MAILTMPLEN]; sprintf (tmp,"%s/%s",home,mailsubdir); myMailboxDir = cpystr (tmp);/* use pre-defined subdirectory of home */ } else myMailboxDir = cpystr (home); - } return myMailboxDir ? myMailboxDir : ""; } @@ -1201,14 +1198,12 @@ case EACCES: /* protection failure? */ MM_CRITICAL (NIL); /* go critical */ if (closedBox || !lockpgm); /* can't do on closed box or disabled */ - else if ((*lockpgm && stat (lockpgm,&sb)) || - (!*lockpgm && stat (lockpgm = LOCKPGM1,&sb) && - stat (lockpgm = LOCKPGM2,&sb) && stat (lockpgm = LOCKPGM3,&sb) && - stat (lockpgm = LOCKPGM4,&sb))) + else if ((*lockpgm && stat (lockpgm,&sb))) lockpgm = NIL; /* disable if can't find lockpgm */ + /* /usr/libexec/lockspool for OpenBSD */ else if (pipe (pi) >= 0) { /* make command pipes */ long cf; - char *argv[4],arg[20]; + char *argv[2]; /* if input pipes usable create output pipes */ if ((pi[0] < FD_SETSIZE) && (pi[1] < FD_SETSIZE) && (pipe (po) >= 0)) { /* make sure output pipes are usable */ @@ -1217,9 +1212,8 @@ else if (!(j = fork ())) { if (!fork ()) { /* make grandchild so it's inherited by init */ /* prepare argument vector */ - sprintf (arg,"%d",fd); - argv[0] = lockpgm; argv[1] = arg; - argv[2] = file; argv[3] = NIL; + argv[0] = lockpgm; /* no args to lockspool for OpenBSD */ + argv[1] = NIL; /* set parent's I/O to my O/I */ dup2 (pi[1],1); dup2 (pi[1],2); dup2 (po[0],0); /* close all unnecessary descriptors */ @@ -1241,7 +1235,8 @@ grim_pid_reap (j,NIL);/* reap child; grandchild now owned by init */ /* read response from locking program */ if (select (pi[0]+1,&rfd,0,0,&tmo) && - (read (pi[0],tmp,1) == 1) && (tmp[0] == '+')) { + (read (pi[0],tmp,1) == 1) && (tmp[0] == '1')) { + /* OpenBSD lockspool uses 1 for successful lock */ /* success, record pipes */ base->pipei = pi[0]; base->pipeo = po[1]; /* close child's side of the pipes */