home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / ixemul-45.0-src.tgz / tar.out / contrib / ixemul / library / multiuser.h < prev    next >
C/C++ Source or Header  |  1996-10-01  |  18KB  |  532 lines

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