#ifndef LIBRARIES_MULTIUSER_H
#define LIBRARIES_MULTIUSER_H
/*
**      $Filename: libraries/multiuser.h $
**      $Release: 1.4 $
**      $Revision: 39.5 $
**
**      multiuser.library definitions
**
**      (C) Copyright 1993 Geert Uytterhoeven
**      All Rights Reserved
*/

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif  /* EXEC_TYPES_H */

#ifndef EXEC_LISTS_H
#include <exec/lists.h>
#endif  /* EXEC_LISTS_H */

#ifndef EXEC_LIBRARIES_H
#include <exec/libraries.h>
#endif  /* EXEC_LIBRARIES_H */

#ifndef LIBRARIES_DOS_H
#include <libraries/dos.h>
#endif  /* LIBRARIES_DOS_H */

#ifndef GRAPHICS_TEXT_H
#include <graphics/text.h>
#endif  /* GRAPHICS_TEXT_H */

#ifndef UTILITY_TAGITEM_H
#include <utility/tagitem.h>
#endif  /* UTILITY_TAGITEM_H */


#define MULTIUSERNAME         "multiuser.library"
#define MULTIUSERVERSION      39


   /*
    *    Reserved users/groups
    *
    *    WARNING: a uid may NOT be zero, a gid may be zero
    */

#define muOWNER_NOBODY  (0x00000000)   /* no rights */
#define muOWNER_SYSTEM  (0xffffffff)   /* always owner */

#define muMASK_UID      (0xffff0000)   /* Mask for uid bits */
#define muMASK_GID      (0x0000ffff)   /* Mask for gid bits */


#define muUSERIDSIZE    (32)           /* Maximum size for a UserID */
#define muPASSWORDSIZE  (32)           /* Maximum size for a Password */
#define muUSERNAMESIZE  (220)          /* Maximum size for a User Name */
#define muHOMEDIRSIZE   (256)          /* Maximum size for a Home Directory */


   /*
    *    Password File
    *
    *
    *    For each user, the Password File must contain a line like this:
    *
    *    <UserID>|<Password>|<uid>|<gid>|<UserName>|<HomeDir>|<Shell>
    *
    *    with:
    *
    *       <UserID>    User Login ID (max. muUSERIDSIZE characters)
    *       <PassKey>   Encrypted Password
    *       <uid>       User Number (1 - 65535)
    *       <gid>       Group Number (0 - 65535)
    *       <UserName>  Full User Name (max. muUSERNAMESIZE characters)
    *       <HomeDir>   Home directory (max. muHOMEDIRSIZE characters)
    *       <Shell>     Default Shell (not used yet, AS225 compatibility)
    */

#define muPasswd_FileName     "passwd"  /* for AS225 compatibility */


   /*
    *    Configuration File
    *
    *
    *    This file contains lines with options in the form <OPT>=<val>.
    *    0 is used for OFF, 1 for ON.
    *    Defaults to the values between square brackets.
    *
    *    LIMITDOSSETPROTECTION   dos.library/SetProtection() cannot change
    *                            protection bits for GROUP and OTHER [1]
    *    PROFILE                 execute the Profile if it exists [1]
    *    LASTLOGINREQ            display the Lastlogin requester [1]
    *    LOGSTARTUP              log startup [0]
    *    LOGLOGIN                log successful logins [0]
    *    LOGLOGINFAIL            log failed logins [0]
    *    LOGPASSWD               log successful password changes [0]
    *    LOGPASSWDFAIL           log failed password changes [0]
    *    LOGCHECKPASSWD          log successful password checks [0]
    *    LOGCHECKPASSWDFAIL      log failed password checks [0]
    *    PASSWDUIDLEVEL          users with a uid greather than or equal to
    *                            <val> can change their passwords [0]
    *    PASSWDGIDLEVEL          users with a gid greather than or equal to
    *                            <val> can change their passwords [0]
    *
    *    NOTE: if a user has a uid less than the PASSWDUIDLEVEL AND a gid
    *          less than PASSWDGIDLEVEL he/she is NOT allowed to change
    *          his/her password!
    */

#define muConfig_FileName     "MultiUser.config"


   /*
    *    Log File
    */

#define muLog_FileName        "MultiUser.log"


   /*
    *    Lastlogin File Name
    */

#define muLastLogin_FileName  ".lastlogin"


   /*
    *    Profile
    */

#define muProfile_FileName    ".profile"


   /*
    *    Key File
    *
    *
    *    This file must be present in the root directory of every volume
    *    that uses the MultiUserFileSystem. It must contain 3 lines:
    *
    *       - a pseudo random ASCII key (max. 1023 characters).
    *       - the directory of the password file, if located on this volume,
    *         otherwise an empty line (no spaces!).
    *           e.g. ":inet/db" for AS225 compatibility
    *       - the directory of the configuration file, if located on this
    *         volume, otherwise an empty line (no spaces!).
    *           e.g. ":MultiUser"
    *
    *    If there is ANY inconsistency the system will refuse to work!!
    */

#define muKey_FileName        ":.MultiUser.keyfile"


   /*
    *    Tags for muLogoutA()/muLoginA()/muSetDefProtectionA()
    */

#define muT_Input          (TAG_USER+1)   /* filehandle - default is Input() */
#define muT_Output         (TAG_USER+2)   /* filehandle - default is Output() */
#define muT_Graphical      (TAG_USER+3)   /* boolean - default is FALSE */
#define muT_PubScrName     (TAG_USER+4)   /* name of public screen */
#define muT_Task           (TAG_USER+5)   /* task (NOT the name!!) */
#define muT_Own            (TAG_USER+6)   /* make a task of this user */
#define muT_Global         (TAG_USER+7)   /* change it for all tasks on the */
                                          /* same level as this one */
#define muT_Quiet          (TAG_USER+8)   /* for muLogoutA(), don't give a */
                                          /* login prompt, simply logout */
#define muT_UserID         (TAG_USER+9)   /* UserID for muLoginA(), must be */
                                          /* used together with muT_Password!! */
#define muT_Password       (TAG_USER+10)  /* Password for muLoginA(), must be */
                                          /* used together with muT_UserID!! */
#define muT_DefProtection  (TAG_USER+11)  /* Default protection bits */
                                          /* default is RWED GROUP R OTHER R */

   /*
    *    Public User Information Structure
    *
    *    For future compatibility, you should ALWAYS use muAllocUserInfo()
    *    to allocate this structure. NEVER do it by yourself!!
    */

struct muUserInfo {
   char UserID[muUSERIDSIZE];
   UWORD uid;
   UWORD gid;
   char UserName[muUSERNAMESIZE];
   char HomeDir[muHOMEDIRSIZE];
};


   /*
    *    KeyTypes for muGetUserInfo
    */

#define muKeyType_First          0
#define muKeyType_Next           1
#define muKeyType_UserID         2  /* Case-sensitive */
#define muKeyType_uid            3
#define muKeyType_gid            4
#define muKeyType_gidNext        5
#define muKeyType_UserName       6  /* Case-insensitive */
#define muKeyType_WUserID        7  /* Case-insensitive, wild cards allowed */
#define muKeyType_WUserName      8  /* Case-insensitive, wild cards allowed */
#define muKeyType_WUserIDNext    9
#define muKeyType_WUserNameNext  10


   /*
    *    Protection bits (see <dos/dos.h>:-)
    */

#define muFIBB_SET_UID        31   /* Change owner during execution */

/* FIBB are bit definitions, FIBF are field definitions */
/* Regular RWED bits are 0 == allowed. */
/* NOTE: GRP and OTR RWED permissions are 0 == not allowed! */

/* #define FIBB_OTR_READ      15   Other: file is readable */
/* #define FIBB_OTR_WRITE     14   Other: file is writable */
/* #define FIBB_OTR_EXECUTE   13   Other: file is executable */
/* #define FIBB_OTR_DELETE    12   Other: prevent file from being deleted */
/* #define FIBB_GRP_READ      11   Group: file is readable */
/* #define FIBB_GRP_WRITE     10   Group: file is writable */
/* #define FIBB_GRP_EXECUTE   9    Group: file is executable */
/* #define FIBB_GRP_DELETE    8    Group: prevent file from being deleted */

/* #define FIBB_SCRIPT        6    program is a script (execute) file */
/* #define FIBB_PURE          5    program is reentrant and rexecutable */
/* #define FIBB_ARCHIVE       4    cleared whenever file is changed */
/* #define FIBB_READ          3    ignored by old filesystem */
/* #define FIBB_WRITE         2    ignored by old filesystem */
/* #define FIBB_EXECUTE       1    ignored by system, used by Shell */
/* #define FIBB_DELETE        0    prevent file from being deleted */

#define muFIBF_SET_UID        (1<<muFIBB_SET_UID)

/* #define FIBF_OTR_READ      (1<<FIBB_OTR_READ) */
/* #define FIBF_OTR_WRITE     (1<<FIBB_OTR_WRITE) */
/* #define FIBF_OTR_EXECUTE   (1<<FIBB_OTR_EXECUTE) */
/* #define FIBF_OTR_DELETE    (1<<FIBB_OTR_DELETE) */
/* #define FIBF_GRP_READ      (1<<FIBB_GRP_READ) */
/* #define FIBF_GRP_WRITE     (1<<FIBB_GRP_WRITE) */
/* #define FIBF_GRP_EXECUTE   (1<<FIBB_GRP_EXECUTE) */
/* #define FIBF_GRP_DELETE    (1<<FIBB_GRP_DELETE) */

/* #define FIBF_SCRIPT        (1<<FIBB_SCRIPT) */
/* #define FIBF_PURE          (1<<FIBB_PURE) */
/* #define FIBF_ARCHIVE       (1<<FIBB_ARCHIVE) */
/* #define FIBF_READ          (1<<FIBB_READ) */
/* #define FIBF_WRITE         (1<<FIBB_WRITE) */
/* #define FIBF_EXECUTE       (1<<FIBB_EXECUTE) */
/* #define FIBF_DELETE        (1<<FIBB_DELETE) */


   /*
    *    Default Protection Bits
    */

#define DEFPROTECTION (FIBF_OTR_READ | FIBF_GRP_READ)



#endif  /* LIBRARIES_MULTIUSER_H */
