* Re: popxd/imapd on osf/DEC enhance security
1994-09-27 17:24 popxd/imapd on osf/DEC enhance security Chris Johnson
@ 1994-10-04 12:12 ` Malcolm Beattie
0 siblings, 0 replies; 2+ messages in thread
From: Malcolm Beattie @ 1994-10-04 12:12 UTC (permalink / raw)
In article <369kg2$hf5@chaos.dac.neu.edu>,
Chris Johnson <johnson@chaos.dac.neu.edu> wrote:
> I'm running U. of Wash. pop & imap d's. They were written for normal
>security and work fine on Ultrix. There's an osf build for them. I suspect
>they would work fine if I wasn't running enhance security. But I am and
>they don't. Ther login secition in c-client/log_std.c: server_login fails.
>That me not be the only thing failing as there are other calls to getpwnam
>etc. scattered here and there.
>
> Has anybody put in the necessary fixes for DEC/osf1's enhanced
>security on these daemons? Where can I find them?
Here's what I did. Firstly, for imap 3.1, a patch to
ANSI/c-client/os_osf.c (you'll also have to link with -lsecurity -laud).
--------------------------- cut here ---------------------------
*** os_osf.c.ORI Fri Aug 26 16:17:19 1994
--- os_osf.c Fri Aug 26 17:16:52 1994
***************
*** 32,37 ****
--- 32,43 ----
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+
+ /*
+ * Modified for C2 Enhanced Security, 26 August 1994
+ * Malcolm Beattie <mbeattie@sable.ox.ac.uk>
+ */
+
/* TCP input buffer */
***************
*** 64,70 ****
#include <pwd.h>
#include <syslog.h>
#include "misc.h"
! extern char *crypt();
/* Write current time in RFC 822 format
* Accepts: destination string
--- 70,79 ----
#include <pwd.h>
#include <syslog.h>
#include "misc.h"
!
! #include <sia.h>
! #include <siad.h>
!
/* Write current time in RFC 822 format
* Accepts: destination string
***************
*** 209,225 ****
long server_login (char *user,char *pass,char **home,int argc,char *argv[])
{
! struct passwd *pw = getpwnam (lcase (user));
! /* no entry for this user or root */
! if (!(pw && pw->pw_uid)) return NIL;
! /* validate password */
! if (strcmp (pw->pw_passwd,(char *) crypt (pass,pw->pw_passwd))) return NIL;
! setgid (pw->pw_gid); /* all OK, login in as that user */
! initgroups (user,pw->pw_gid); /* initialize groups */
! setuid (pw->pw_uid);
! /* note home directory */
! if (home) *home = cpystr (pw->pw_dir);
! return T;
}
/* Return my user name
--- 218,258 ----
long server_login (char *user,char *pass,char **home,int argc,char *argv[])
{
! SIAENTITY *entity = NULL;
! int sia_argc;
! char *sia_argv[3];
! static int stderr_closed = 0; /* workaround for OSF/1 T3.0-2 bug */
!
! sia_argc = 2;
! sia_argv[0] = "imapd";
! sia_argv[1] = user;
! sia_argv[2] = NULL;
! if (sia_ses_init(&entity, sia_argc, sia_argv,
! NULL, user, NULL, FALSE, NULL) != SIASUCCESS)
! fatal("sia_ses_init failed");
! if (!stderr_closed)
! {
! /* In OSF/1 T3.0-2, if sia_ses_authent is given a wrong password
! it writes an audgenl error message to stderr. */
! fclose(stderr);
! stderr_closed = 1;
! }
! /* Check they have the correct password */
! if (sia_ses_authent(NULL, pass, entity) != SIASUCCESS)
! return NIL;
! /* Check they are allowed to login */
! if (sia_ses_estab(NULL, entity) != SIASUCCESS)
! return NIL;
!
! setgid(entity->pwd->pw_gid); /* all OK, login in as that user */
! initgroups(user, entity->pwd->pw_gid); /* initialize groups */
! setuid (entity->pwd->pw_uid);
! /* note home directory */
! if (home)
! *home = cpystr(entity->pwd->pw_dir);
! if (sia_ses_release(&entity) != SIASUCCESS)
! fatal("sia_ses_release failed");
! return T;
}
/* Return my user name
***************
*** 226,236 ****
* Returns: my user name
*/
! char *uname = NIL;
char *myusername ()
{
! return uname ? uname : (uname = cpystr (getpwuid (geteuid ())->pw_name));
}
--- 259,270 ----
* Returns: my user name
*/
! char *username = NIL;
char *myusername ()
{
! return username ? username
! : (username = cpystr(getpwuid (geteuid ())->pw_name));
}
--------------------------- cut here ---------------------------
Now for the popserver patch:
--------------------------- cut here ---------------------------
*** popper.h.ORI Wed Aug 24 14:17:20 1994
--- popper.h Wed Aug 24 14:56:29 1994
***************
*** 24,29 ****
--- 24,32 ----
#define FALSE 0
#define NEWLINE '\n'
+ #ifdef MAXHOSTNAMELEN
+ #undef MAXHOSTNAMELEN
+ #endif /* MAXHOSTNAMELEN */
#define MAXHOSTNAMELEN 256
#define MAXUSERNAMELEN 65
#define MAXDROPLEN 64
***************
*** 33,51 ****
#define MAXPARMCOUNT 5
#define MAXPARMLEN 10
#define ALLOC_MSGS 20
! #define MAIL_COMMAND "/usr/lib/sendmail"
! #define POP_FACILITY LOG_LOCAL0
#define POP_PRIORITY LOG_NOTICE
#define POP_DEBUG LOG_DEBUG
#define POP_LOGOPTS 0
! #define POP_MAILDIR "/usr/spool/mail"
! #define POP_DROP "/usr/spool/mail/.%s.pop"
/* POP_TMPSIZE needs to be big enough to hold the string
* defined by POP_TMPDROP. POP_DROP and POP_TMPDROP
* must be in the same filesystem.
*/
! #define POP_TMPDROP "/usr/spool/mail/tmpXXXXXX"
#define POP_TMPSIZE 256
#define POP_TMPXMIT "/tmp/xmitXXXXXX"
#define POP_OK "+OK"
--- 36,54 ----
#define MAXPARMCOUNT 5
#define MAXPARMLEN 10
#define ALLOC_MSGS 20
! #define MAIL_COMMAND "/usr/sbin/sendmail"
! #define POP_FACILITY LOG_LOCAL2
#define POP_PRIORITY LOG_NOTICE
#define POP_DEBUG LOG_DEBUG
#define POP_LOGOPTS 0
! #define POP_MAILDIR "/var/spool/mail"
! #define POP_DROP "/var/spool/mail/.%s.pop"
/* POP_TMPSIZE needs to be big enough to hold the string
* defined by POP_TMPDROP. POP_DROP and POP_TMPDROP
* must be in the same filesystem.
*/
! #define POP_TMPDROP "/var/spool/mail/tmpXXXXXX"
#define POP_TMPSIZE 256
#define POP_TMPXMIT "/tmp/xmitXXXXXX"
#define POP_OK "+OK"
*** popper.c.ORI Wed Aug 24 12:48:06 1994
--- popper.c Fri Aug 26 15:14:58 1994
***************
*** 13,18 ****
--- 13,23 ----
#include <sys/types.h>
#include "popper.h"
+ #ifdef __osf__
+ /* Want prototype for set_auth_parameters */
+ #include <prot.h>
+ #endif /* __osf__ */
+
extern state_table * pop_get_command();
/*
***************
*** 26,33 ****
--- 31,47 ----
state_table * s;
char message[MAXLINELEN];
+ #ifdef __osf__
+ set_auth_parameters(argc, argv);
+ #endif /* __osf__ */
+
/* Start things rolling */
pop_init(&p,argc,argv);
+
+ #ifdef __osf__
+ fclose(stderr); /* workaround for OSF/1 T3.0-2 bug in */
+ /* sia_ses_authent */
+ #endif /* __osf __ */
/* Tell the user that we are listenting */
pop_msg(&p,POP_SUCCESS,
*** pop_pass.c.ORI Wed Aug 24 12:32:23 1994
--- pop_pass.c Wed Aug 24 13:41:07 1994
***************
*** 3,8 ****
--- 3,9 ----
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
+ /* Rewritten for OSF/1 C2 Enhanced Security. Malcolm Beattie 24 Aug 1994 */
#ifndef lint
static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
***************
*** 15,20 ****
--- 16,48 ----
#include <pwd.h>
#include "popper.h"
+ #include <sia.h>
+ #include <siad.h>
+ #include <string.h>
+
+ static char *sia_reason = NULL;
+
+ int sia_collect_cache(int timeout, int rendition, unsigned char *title,
+ int num_prompts, prompt_t *prompt)
+ {
+ size_t len;
+
+ if (rendition == SIAINFO || rendition == SIAWARNING)
+ {
+ if (sia_reason)
+ free(sia_reason);
+ sia_reason = strdup(prompt->prompt);
+ /* Truncate trailing newline if present */
+ if (sia_reason)
+ {
+ len = strlen(sia_reason);
+ if (len > 0 && sia_reason[len - 1] == '\n')
+ sia_reason[len - 1] = '\0';
+ }
+ }
+ return SIACOLSUCCESS;
+ }
+
/*
* pass: Obtain the user password from a POP client
*/
***************
*** 22,44 ****
int pop_pass (p)
POP * p;
{
! register struct passwd * pw;
! char *crypt();
! /* Look for the user in the password file */
if ((pw = getpwnam(p->user)) == NULL)
return (pop_msg(p,POP_FAILURE,
! "Password supplied for \"%s\" is incorrect.",p->user));
!
! /* We don't accept connections from users with null passwords */
! if (pw->pw_passwd == NULL)
! return (pop_msg(p,POP_FAILURE,
! "Password supplied for \"%s\" is incorrect.",p->user));
!
! /* Compare the supplied password with the password file entry */
! if (strcmp (crypt (p->pop_parm[1], pw->pw_passwd), pw->pw_passwd) != 0)
! return (pop_msg(p,POP_FAILURE,
! "Password supplied for \"%s\" is incorrect.",p->user));
/* Build the name of the user's maildrop */
(void)sprintf(p->drop_name,"%s/%s",POP_MAILDIR,p->user);
--- 50,87 ----
int pop_pass (p)
POP * p;
{
! struct passwd *pw;
! SIAENTITY *entity = NULL;
! int sia_argc;
! char *sia_argv[3];
! sia_argc = 2;
! sia_argv[0] = "popper";
! sia_argv[1] = p->user;
! sia_argv[2] = NULL;
! if (sia_ses_init(&entity, sia_argc, sia_argv,
! NULL, p->user, NULL, FALSE, NULL) != SIASUCCESS)
! {
! pop_log(p, POP_PRIORITY, "sia_ses_init failed");
! return (pop_msg(p, POP_FAILURE,
! "System error, SIA authentication problem"));
! }
! if (sia_ses_authent(sia_collect_cache,
! p->pop_parm[1], entity) != SIASUCCESS)
! return (pop_msg(p,POP_FAILURE,
! sia_reason ? sia_reason : "Authentication error"));
! if (sia_ses_estab(sia_collect_cache, entity) != SIASUCCESS)
! return (pop_msg(p,POP_FAILURE,
! sia_reason ? sia_reason : "Authentication error"));
! if (sia_ses_release(&entity) != SIASUCCESS)
! pop_log(p, POP_PRIORITY, "sia_ses_release failed");
!
if ((pw = getpwnam(p->user)) == NULL)
+ {
+ pop_log(p, POP_PRIORITY, "getpwnam failed after sia_ses succeeded");
return (pop_msg(p,POP_FAILURE,
! "System error, SIA authentication problem"));
! }
/* Build the name of the user's maildrop */
(void)sprintf(p->drop_name,"%s/%s",POP_MAILDIR,p->user);
*** Makefile~ Wed Aug 24 14:29:08 1994
--- Makefile Wed Aug 24 15:07:42 1994
***************
*** 38,44 ****
# syslog).
# STRNCASECMP - If you do not have strncasecmp()
! CFLAGS = -O -DHAVE_VSPRINTF
TARGET = popper
--- 38,44 ----
# syslog).
# STRNCASECMP - If you do not have strncasecmp()
! CFLAGS = -O -DHAVE_VSPRINTF -D_BSD
TARGET = popper
***************
*** 55,61 ****
${TARGET}: ${OBJS}
! cc ${OBJS} -o ${TARGET}
tar: ${SRCS} ${DOCS} ${MAKEFILE}
rm -f ${TAR} *.Z*
--- 55,61 ----
${TARGET}: ${OBJS}
! cc ${OBJS} -o ${TARGET} -lsecurity -laud
tar: ${SRCS} ${DOCS} ${MAKEFILE}
rm -f ${TAR} *.Z*
--------------------------- cut here ---------------------------
--Malcolm
--
Malcolm Beattie <mbeattie@sable.ox.ac.uk> (note new address)
Oxford University Computing Services
"Widget. It's got a widget. A lovely widget. A widget it has got." --Jack Dee
^ permalink raw reply [flat|nested] 2+ messages in thread