home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / dec93 / os20 / util / multiuser.lha / MultiUser / Include / libraries / multiuser.h < prev   
Encoding:
C/C++ Source or Header  |  1993-12-21  |  16.7 KB  |  502 lines

  1. #ifndef LIBRARIES_MULTIUSER_H
  2. #define LIBRARIES_MULTIUSER_H
  3. /*
  4. **      $VER: multiuser.h 39.10 (12.9.93)
  5. **      MultiUser Release 1.5
  6. **
  7. **      multiuser.library definitions
  8. **
  9. **      (C) Copyright 1993 Geert Uytterhoeven
  10. **          All Rights Reserved
  11. */
  12.  
  13. #ifndef EXEC_TYPES_H
  14. #include <exec/types.h>
  15. #endif  /* EXEC_TYPES_H */
  16.  
  17. #ifndef EXEC_LISTS_H
  18. #include <exec/lists.h>
  19. #endif  /* EXEC_LISTS_H */
  20.  
  21. #ifndef EXEC_LIBRARIES_H
  22. #include <exec/libraries.h>
  23. #endif  /* EXEC_LIBRARIES_H */
  24.  
  25. #ifndef LIBRARIES_DOS_H
  26. #include <libraries/dos.h>
  27. #endif  /* LIBRARIES_DOS_H */
  28.  
  29. #ifndef GRAPHICS_TEXT_H
  30. #include <graphics/text.h>
  31. #endif  /* GRAPHICS_TEXT_H */
  32.  
  33. #ifndef UTILITY_TAGITEM_H
  34. #include <utility/tagitem.h>
  35. #endif  /* UTILITY_TAGITEM_H */
  36.  
  37.  
  38. #define MULTIUSERNAME         "multiuser.library"
  39. #define MULTIUSERVERSION      (39)
  40.  
  41.  
  42.    /*
  43.     *    Reserved users/groups
  44.     *
  45.     *    WARNING: a uid may NOT be zero, a gid may be zero
  46.     */
  47.  
  48. #define muOWNER_NOBODY  (0x00000000)   /* no rights */
  49. #define muOWNER_SYSTEM  (0xffffffff)   /* always owner */
  50.  
  51. #define muMASK_UID      (0xffff0000)   /* Mask for uid bits */
  52. #define muMASK_GID      (0x0000ffff)   /* Mask for gid bits */
  53.  
  54. #define muROOT_UID      (0xffff)       /* super user uid */
  55. #define muROOT_GID      (0xffff)       /* super user gid */
  56.  
  57. #define muNOBODY_UID    (0x0000)       /* nobody uid */
  58.  
  59. #define muUSERIDSIZE    (32)           /* Maximum size for a User ID */
  60. #define muGROUPIDSIZE   (32)           /* Maximum size for a Group ID */
  61. #define muPASSWORDSIZE  (32)           /* Maximum size for a Password */
  62. #define muUSERNAMESIZE  (220)          /* Maximum size for a User Name */
  63. #define muGROUPNAMESIZE (220)          /* Maximum size for a Group Name */
  64. #define muHOMEDIRSIZE   (256)          /* Maximum size for a Home Directory */
  65.  
  66.  
  67.    /*
  68.     *    Password File
  69.     *
  70.     *
  71.     *    For each user, the Password File must contain a line like this:
  72.     *
  73.     *    <UserID>|<Password>|<uid>|<gid>|<UserName>|<HomeDir>|<Shell>
  74.     *
  75.     *    with:
  76.     *
  77.     *       <UserID>    User Login ID (max. muUSERIDSIZE-1 characters)
  78.     *       <PassKey>   Encrypted Password
  79.     *       <uid>       User Number (1 - 65535)
  80.     *       <gid>       Primary Group Number (0 - 65535)
  81.     *       <UserName>  Full User Name (max. muUSERNAMESIZE-1 characters)
  82.     *       <HomeDir>   Home directory (max. muHOMEDIRSIZE-1 characters)
  83.     *       <Shell>     Default Shell (not used yet, AS225 compatibility)
  84.     */
  85.  
  86. #define muPasswd_FileName     "passwd"  /* for AS225 compatibility */
  87.  
  88.  
  89.    /*
  90.     *    Group File
  91.     *
  92.     *
  93.     *    This file gives more information about the groups and defines
  94.     *    the secondary groups (other than the primary group) a user
  95.     *    belongs to. It exists out of two parts, separated by a blank line.
  96.     *
  97.     *    The first part contains lines with the format:
  98.     *
  99.     *    <GroupID>|<gid>|<MgrUid>|<GroupName>
  100.     *
  101.     *    with:
  102.     *
  103.     *       <GroupID>   Group short ID (max. muGROUPIDSIZE-1 characters)
  104.     *       <gid>       Group Number (0 - 65535)
  105.     *       <MgrUid>    User Number of this group's manager, 0 for no
  106.     *                   manager. A group's manager must not belong to the
  107.     *                   group.
  108.     *       <GroupName> Full Group Name (max. muGROUPNAMESIZE-1 characters)
  109.     *
  110.     *    NOTE: Not every group must have a line in this file, but at least
  111.     *          one group must have one.
  112.     *
  113.     *
  114.     *    The seconds part contains lines with the format:
  115.     *
  116.     *    <uid>:<gid>[,<gid>...]
  117.     *
  118.     *    with:
  119.     *
  120.     *       <uid>       User Number (1-65535)
  121.     *       <gid>       Group Number (0 - 65535)
  122.     *
  123.     *    If you think you'll exceed the maximum line length (circa 1K),
  124.     *    you may use more than one line per user.
  125.     */
  126.  
  127. #define muGroup_FileName      "MultiUser.group"
  128.  
  129.  
  130.    /*
  131.     *    Configuration File
  132.     *
  133.     *
  134.     *    This file contains lines with options in the form <OPT>=<val>.
  135.     *    0 is used for OFF, 1 for ON.
  136.     *    Defaults to the values between square brackets.
  137.     *
  138.     *    LIMITDOSSETPROTECTION   dos.library/SetProtection() cannot change
  139.     *                            protection bits for GROUP and OTHER [1]
  140.     *    PROFILE                 execute the Profile if it exists [1]
  141.     *    LASTLOGINREQ            display the Lastlogin requester [1]
  142.     *    LOGSTARTUP              log startup [0]
  143.     *    LOGLOGIN                log successful logins [0]
  144.     *    LOGLOGINFAIL            log failed logins [0]
  145.     *    LOGPASSWD               log successful password changes [0]
  146.     *    LOGPASSWDFAIL           log failed password changes [0]
  147.     *    LOGCHECKPASSWD          log successful password checks [0]
  148.     *    LOGCHECKPASSWDFAIL      log failed password checks [0]
  149.     *    PASSWDUIDLEVEL          users with a uid greather than or equal to
  150.     *                            <val> can change their passwords [0]
  151.     *    PASSWDGIDLEVEL          users with a gid greather than or equal to
  152.     *                            <val> can change their passwords [0]
  153.     *
  154.     *    NOTE: if a user has a uid less than the PASSWDUIDLEVEL AND a gid
  155.     *          less than PASSWDGIDLEVEL he/she is NOT allowed to change
  156.     *          his/her password!
  157.     */
  158.  
  159. #define muConfig_FileName     "MultiUser.config"
  160.  
  161.  
  162.    /*
  163.     *    Log File
  164.     */
  165.  
  166. #define muLog_FileName        "MultiUser.log"
  167.  
  168.  
  169.    /*
  170.     *    Lastlogin File
  171.     */
  172.  
  173. #define muLastLogin_FileName  ".lastlogin"
  174.  
  175.  
  176.    /*
  177.     *    Profile
  178.     */
  179.  
  180. #define muProfile_FileName    ".profile"
  181.  
  182.  
  183.    /*
  184.     *    Plan file
  185.     */
  186.  
  187. #define muPlan_FileName       ".plan"
  188.  
  189.  
  190.    /*
  191.     *    Key File
  192.     *
  193.     *
  194.     *    This file must be present in the root directory of every volume
  195.     *    that uses the MultiUserFileSystem. It must contain 3 lines:
  196.     *
  197.     *       - a pseudo random ASCII key (max. 1023 characters).
  198.     *       - the directory of the password file, if located on this volume,
  199.     *         otherwise an empty line (no spaces!).
  200.     *           e.g. ":inet/db" for AS225 compatibility
  201.     *       - the directory of the configuration file, if located on this
  202.     *         volume, otherwise an empty line (no spaces!).
  203.     *           e.g. ":MultiUser"
  204.     *
  205.     *    If there is ANY inconsistency the system will refuse to work!!
  206.     */
  207.  
  208. #define muKey_FileName        ":.MultiUser.keyfile"
  209.  
  210.  
  211.    /*
  212.     *    Tags for muLogoutA()
  213.     *             muLoginA()
  214.     *             muSetDefProtectionA()
  215.     */
  216.  
  217. #define muT_Input          (TAG_USER+1)   /* filehandle - default is Input() */
  218. #define muT_Output         (TAG_USER+2)   /* filehandle - default is Output() */
  219. #define muT_Graphical      (TAG_USER+3)   /* boolean - default is FALSE */
  220. #define muT_PubScrName     (TAG_USER+4)   /* name of public screen */
  221. #define muT_Task           (TAG_USER+5)   /* task (NOT the name!!) */
  222. #define muT_Own            (TAG_USER+6)   /* make a task owned by this user */
  223. #define muT_Global         (TAG_USER+7)   /* change it for all tasks on the */
  224.                                           /* same level as this one */
  225. #define muT_Quiet          (TAG_USER+8)   /* for muLogoutA(), don't give a */
  226.                                           /* login prompt, simply logout */
  227. #define muT_UserID         (TAG_USER+9)   /* UserID for muLoginA(), must be */
  228.                                           /* used together with muT_Password!! */
  229. #define muT_Password       (TAG_USER+10)  /* Password for muLoginA(), must be */
  230.                                           /* used together with muT_UserID!! */
  231. #define muT_DefProtection  (TAG_USER+11)  /* Default protection bits */
  232.                                           /* default is RWED GROUP R OTHER R */
  233. #define muT_All            (TAG_USER+12)  /* for muLogoutA(), logout until */
  234.                                           /* user stack is empty */
  235.  
  236.  
  237.    /*
  238.     *    Public User Information Structure
  239.     *
  240.     *
  241.     *    For future compatibility, you should ALWAYS use muAllocUserInfo()
  242.     *    to allocate this structure. NEVER do it by yourself!!
  243.     */
  244.  
  245. struct muUserInfo {
  246.    char UserID[muUSERIDSIZE];
  247.    UWORD uid;
  248.    UWORD gid;
  249.    char UserName[muUSERNAMESIZE];
  250.    char HomeDir[muHOMEDIRSIZE];
  251.    UWORD NumSecGroups;              /* Number of Secondary Groups this */
  252.                                     /* user belongs to */
  253.    UWORD *SecGroups;                /* Points to an array of NumSecGroups */
  254.                                     /* Secondary Group Numbers */
  255. };
  256.  
  257.  
  258.    /*
  259.     *    Public Group Information Structure
  260.     *
  261.     *
  262.     *    For future compatibility, you should ALWAYS use muAllocGroupInfo()
  263.     *    to allocate this structure. NEVER do it by yourself!!
  264.     */
  265.  
  266. struct muGroupInfo {
  267.    char GroupID[muGROUPIDSIZE];
  268.    UWORD gid;
  269.    UWORD MgrUid;                    /* Manager of this group */
  270.    char GroupName[muGROUPNAMESIZE];
  271. };
  272.  
  273.  
  274.    /*
  275.     *    KeyTypes for muGetUserInfo()
  276.     *                 muGetGroupInfo()
  277.     */
  278.  
  279. #define muKeyType_First          (0)
  280. #define muKeyType_Next           (1)
  281. #define muKeyType_gid            (4)
  282.  
  283.    /*
  284.     *    KeyTypes for muGetUserInfo() only
  285.     */
  286.  
  287. #define muKeyType_UserID         (2)   /* Case-sensitive */
  288. #define muKeyType_uid            (3)
  289. #define muKeyType_gidNext        (5)
  290. #define muKeyType_UserName       (6)   /* Case-insensitive */
  291. #define muKeyType_WUserID        (7)   /* Case-insensitive, wild cards allowed */
  292. #define muKeyType_WUserName      (8)   /* Case-insensitive, wild cards allowed */
  293. #define muKeyType_WUserIDNext    (9)
  294. #define muKeyType_WUserNameNext  (10)
  295.  
  296.    /*
  297.     *    KeyTypes for muGetGroupInfo() only
  298.     */
  299.  
  300. #define muKeyType_GroupID        (11)  /* Case-sensitive */
  301. #define muKeyType_WGroupID       (12)  /* Case-insensitive, wild cards allowed */
  302. #define muKeyType_WGroupIDNext   (13)
  303. #define muKeyType_GroupName      (14)  /* Case-insensitive */
  304. #define muKeyType_WGroupName     (15)  /* Case-insensitive, wild cards allowed */
  305. #define muKeyType_WGroupNameNext (16)
  306. #define muKeyType_MgrUid         (17)
  307. #define muKeyType_MgrUidNext     (18)
  308.  
  309.  
  310.    /*
  311.     *    Extended Owner Information Structure
  312.     *
  313.     *
  314.     *    A pointer to this structure is returned by muGetTaskExtOwner().
  315.     *    You MUST use muFreeExtOwner() to deallocate it!!
  316.     */
  317.  
  318. struct muExtOwner {
  319.    UWORD uid;
  320.    UWORD gid;
  321.    UWORD NumSecGroups;              /* Number of Secondary Groups this */
  322.                                     /* user belongs too. */
  323. };
  324.  
  325.    /* NOTE: This structure is followed by a UWORD array containing */
  326.    /*       the Secondary Group Numbers */
  327.    /*       Use the following macro to access these group numbers, */
  328.    /*       e.g. sgid = muSecGroups(extowner)[i]; */
  329.  
  330. #define muSecGroups(x) ((UWORD *)((UBYTE *)x+sizeof(struct muExtOwner)))
  331.  
  332.  
  333.    /*
  334.     *    Macro to convert an Extended Owner Information Structure to a ULONG
  335.     *    (cfr. muGetTaskOwner())
  336.     *
  337.     *    Do not use this macro on a NULL pointer!!
  338.     */
  339.  
  340. #define muExtOwner2ULONG(x) ((ULONG)(x ? x->uid<<16|x->gid : NULL))
  341.  
  342.  
  343.    /*
  344.     *    Protection bits (see also <dos/dos.h> :-)
  345.     */
  346.  
  347. #define muFIBB_SET_UID        (31)  /* Change owner during execution */
  348.  
  349. /* FIBB are bit definitions, FIBF are field definitions */
  350. /* Regular RWED bits are 0 == allowed. */
  351. /* NOTE: GRP and OTR RWED permissions are 0 == not allowed! */
  352.  
  353. /* #define FIBB_OTR_READ      15   Other: file is readable */
  354. /* #define FIBB_OTR_WRITE     14   Other: file is writable */
  355. /* #define FIBB_OTR_EXECUTE   13   Other: file is executable */
  356. /* #define FIBB_OTR_DELETE    12   Other: prevent file from being deleted */
  357. /* #define FIBB_GRP_READ      11   Group: file is readable */
  358. /* #define FIBB_GRP_WRITE     10   Group: file is writable */
  359. /* #define FIBB_GRP_EXECUTE   9    Group: file is executable */
  360. /* #define FIBB_GRP_DELETE    8    Group: prevent file from being deleted */
  361.  
  362. /* #define FIBB_SCRIPT        6    program is a script (execute) file */
  363. /* #define FIBB_PURE          5    program is reentrant and rexecutable */
  364. /* #define FIBB_ARCHIVE       4    cleared whenever file is changed */
  365. /* #define FIBB_READ          3    ignored by old filesystem */
  366. /* #define FIBB_WRITE         2    ignored by old filesystem */
  367. /* #define FIBB_EXECUTE       1    ignored by system, used by Shell */
  368. /* #define FIBB_DELETE        0    prevent file from being deleted */
  369.  
  370. #define muFIBF_SET_UID        (1<<muFIBB_SET_UID)
  371.  
  372. /* #define FIBF_OTR_READ      (1<<FIBB_OTR_READ) */
  373. /* #define FIBF_OTR_WRITE     (1<<FIBB_OTR_WRITE) */
  374. /* #define FIBF_OTR_EXECUTE   (1<<FIBB_OTR_EXECUTE) */
  375. /* #define FIBF_OTR_DELETE    (1<<FIBB_OTR_DELETE) */
  376. /* #define FIBF_GRP_READ      (1<<FIBB_GRP_READ) */
  377. /* #define FIBF_GRP_WRITE     (1<<FIBB_GRP_WRITE) */
  378. /* #define FIBF_GRP_EXECUTE   (1<<FIBB_GRP_EXECUTE) */
  379. /* #define FIBF_GRP_DELETE    (1<<FIBB_GRP_DELETE) */
  380.  
  381. /* #define FIBF_SCRIPT        (1<<FIBB_SCRIPT) */
  382. /* #define FIBF_PURE          (1<<FIBB_PURE) */
  383. /* #define FIBF_ARCHIVE       (1<<FIBB_ARCHIVE) */
  384. /* #define FIBF_READ          (1<<FIBB_READ) */
  385. /* #define FIBF_WRITE         (1<<FIBB_WRITE) */
  386. /* #define FIBF_EXECUTE       (1<<FIBB_EXECUTE) */
  387. /* #define FIBF_DELETE        (1<<FIBB_DELETE) */
  388.  
  389.  
  390.    /*
  391.     *    Default Protection Bits
  392.     */
  393.  
  394. #define DEFPROTECTION (FIBF_OTR_READ | FIBF_GRP_READ)
  395.  
  396.  
  397.    /*
  398.     *    Relations returned by muGetRelationshipA()
  399.     */
  400.  
  401. #define muRelB_ROOT_UID    (0)   /* User == super user */
  402. #define muRelB_ROOT_GID    (1)   /* User belongs to the super user group */
  403. #define muRelB_NOBODY      (2)   /* User == nobody */
  404. #define muRelB_UID_MATCH   (3)   /* User == owner */
  405. #define muRelB_GID_MATCH   (4)   /* User belongs to owner group */
  406. #define muRelB_PRIM_GID    (5)   /* User's primary group == owner group */
  407. #define muRelB_NO_OWNER    (6)   /* Owner == nobody */
  408.  
  409. #define muRelF_ROOT_UID    (1<<muRelB_ROOT_UID)
  410. #define muRelF_ROOT_GID    (1<<muRelB_ROOT_GID)
  411. #define muRelF_NOBODY      (1<<muRelB_NOBODY)
  412. #define muRelF_UID_MATCH   (1<<muRelB_UID_MATCH)
  413. #define muRelF_GID_MATCH   (1<<muRelB_GID_MATCH)
  414. #define muRelF_PRIM_GID    (1<<muRelB_PRIM_GID)
  415. #define muRelF_NO_OWNER    (1<<muRelB_NO_OWNER)
  416.  
  417.  
  418.    /*
  419.     *    Monitor Structure
  420.     *
  421.     *
  422.     *    The use of this structure is restricted to root.
  423.     *    Do not modify or reuse this structure while it is active!
  424.     */
  425.  
  426. struct muMonitor {
  427.    struct MinNode Node;
  428.    ULONG Mode;                      /* see definitions below */
  429.    ULONG Triggers;                  /* see definitions below */
  430.    union {
  431.       struct {                      /* for SEND_SIGNAL */
  432.          struct Task *Task;
  433.          ULONG SignalNum;
  434.       } Signal;
  435.  
  436.       struct {                      /* for SEND_MESSAGE */
  437.          struct MsgPort *Port;
  438.       } Message;
  439.    };
  440.  
  441.    /* NOTE: This structure may be extended in future! */
  442. };
  443.  
  444.    /*
  445.     *    Monitor Modes
  446.     */
  447.  
  448. #define muMon_IGNORE       (0)
  449. #define muMon_SEND_SIGNAL  (1)
  450. #define muMon_SEND_MESSAGE (2)
  451.  
  452.    /*
  453.     *    Monitor Message
  454.     *
  455.     *
  456.     *    Sent to the application if SEND_MESSAGE is specified.
  457.     *    Do NOT forget to reply!
  458.     */
  459.  
  460. struct muMonMsg {
  461.    struct Message ExecMsg;
  462.    struct muMonitor *Monitor;       /* The monitor that sent the message */
  463.    ULONG Trigger;                   /* The trigger that caused the message */
  464.    UWORD From;
  465.    UWORD To;
  466.    char UserID[muUSERIDSIZE];
  467. };
  468.  
  469.    /*
  470.     *    Monitor Triggers
  471.     */
  472.  
  473. #define muTrgB_OwnerChange       (0)   /* Task Owner Change */
  474.                                        /*    From:    uid of old user */
  475.                                        /*    To:      uid of new user */
  476. #define muTrgB_Login             (1)   /* successful Login/Logout */
  477.                                        /*    From:    uid of old user */
  478.                                        /*    To:      uid of new user */
  479.                                        /*    UserID:  UserID of new user */
  480. #define muTrgB_LoginFail         (2)   /* unsuccessful Login/Logout */
  481.                                        /*    From:    uid of old user */
  482.                                        /*    UserID:  UserID of new user */
  483. #define muTrgB_Passwd            (3)   /* successful Passwd */
  484.                                        /*    From:    uid of user */
  485. #define muTrgB_PasswdFail        (4)   /* unsuccessful Passwd */
  486.                                        /*    From:    uid of user */
  487. #define muTrgB_CheckPasswd       (5)   /* successful CheckPasswd */
  488.                                        /*    From:    uid of user */
  489. #define muTrgB_CheckPasswdFail   (6)   /* unsuccessful CheckPasswd */
  490.                                        /*    From:    uid of user */
  491.  
  492. #define muTrgF_OwnerChange       (1<<muTrgB_OwnerChange)
  493. #define muTrgF_Login             (1<<muTrgB_Login)
  494. #define muTrgF_LoginFail         (1<<muTrgB_LoginFail)
  495. #define muTrgF_Passwd            (1<<muTrgB_Passwd)
  496. #define muTrgF_PasswdFail        (1<<muTrgB_PasswdFail)
  497. #define muTrgF_CheckPasswd       (1<<muTrgB_CheckPasswd)
  498. #define muTrgF_CheckPasswdFail   (1<<muTrgB_CheckPasswdFail)
  499.  
  500.  
  501. #endif  /* LIBRARIES_MULTIUSER_H */
  502.