1 /* ======================================================================== 2 * Copyright 2008-2010 Mark Crispin 3 * ======================================================================== 4 */ 5 6 /* 7 * Program: UNIX environment routines 8 * 9 * Author: Mark Crispin 10 * 11 * Date: 1 August 1988 12 * Last Edited: 15 November 2010 13 * 14 * Previous versions of this file were: 15 * 16 * Copyright 1988-2006 University of Washington 17 * 18 * Licensed under the Apache License, Version 2.0 (the "License"); 19 * you may not use this file except in compliance with the License. 20 * You may obtain a copy of the License at 21 * 22 * http://www.apache.org/licenses/LICENSE-2.0 23 * 24 */ 25 26 27 typedef struct dotlock_base { 28 char lock[MAILTMPLEN]; 29 int pipei; 30 int pipeo; 31 } DOTLOCK; 32 33 34 /* Bits that can be set in restrictBox */ 35 36 #define RESTRICTROOT 0x1 /* restricted box doesn't allow root */ 37 #define RESTRICTOTHERUSER 0x2 /* restricted box doesn't allow other user */ 38 39 /* Subscription definitions for UNIX */ 40 41 #define SUBSCRIPTIONFILE(t) sprintf (t,"%s/.mailboxlist",myhomedir ()) 42 #define SUBSCRIPTIONTEMP(t) sprintf (t,"%s/.mlbxlsttmp",myhomedir ()) 43 44 45 /* dorc() options */ 46 47 #define SYSCONFIG "/etc/c-client.cf" 48 49 50 /* Special users */ 51 52 #define ANONYMOUSUSER "nobody" /* anonymous user */ 53 #define UNLOGGEDUSER "root" /* unlogged-in user */ 54 #define ADMINGROUP "mailadm" /* mail administrator group */ 55 56 /* Function prototypes */ 57 58 #include "env.h" 59 60 void rfc822_fixed_date (char *date); 61 long env_init (char *user,char *home); 62 char *myusername_full (unsigned long *flags); 63 #define MU_LOGGEDIN 0 64 #define MU_NOTLOGGEDIN 1 65 #define MU_ANONYMOUS 2 66 #define myusername() \ 67 myusername_full (NIL) 68 char *sysinbox (void); 69 char *mailboxdir (char *dst,char *dir,char *name); 70 long dotlock_lock (char *file,DOTLOCK *base,int fd); 71 long dotlock_unlock (DOTLOCK *base); 72 int lockname (char *lock,char *fname,int op,long *pid); 73 int lockfd (int fd,char *lock,int op); 74 int lock_work (char *lock,void *sbuf,int op,long *pid); 75 long chk_notsymlink (char *name,void *sbuf); 76 void unlockfd (int fd,char *lock); 77 long set_mbx_protections (char *mailbox,char *path); 78 long get_dir_protection (char *mailbox); 79 MAILSTREAM *user_flags (MAILSTREAM *stream); 80 char *default_user_flag (unsigned long i); 81 void dorc (char *file,long flag); 82 long path_create (MAILSTREAM *stream,char *mailbox); 83 void grim_pid_reap_status (int pid,int killreq,void *status); 84 #define grim_pid_reap(pid,killreq) \ 85 grim_pid_reap_status (pid,killreq,NIL) 86 long safe_write (int fd,char *buf,long nbytes); 87 void *arm_signal (int sig,void *action); 88 struct passwd *checkpw (struct passwd *pw,char *pass,int argc,char *argv[]); 89 long loginpw (struct passwd *pw,int argc,char *argv[]); 90 long pw_login (struct passwd *pw,char *auser,char *user,char *home,int argc, 91 char *argv[]); 92 void *mm_blocknotify (int reason,void *data); 93