]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/sys/spawn_internal.h
xnu-6153.61.1.tar.gz
[apple/xnu.git] / bsd / sys / spawn_internal.h
index 64877ea3dffed8117a7b8d52dd1f4f216514cad8..d963cfdb9726f4fe44d720fbd5670255261c372d 100644 (file)
@@ -76,6 +76,7 @@ typedef enum {
        PSPA_EXCEPTION = 1,
        PSPA_AU_SESSION = 2,
        PSPA_IMP_WATCHPORTS = 3,
+       PSPA_REGISTERED_PORTS = 4,
 } pspa_t;
 
 /*
@@ -150,6 +151,24 @@ struct _posix_spawn_coalition_info {
        } psci_info[COALITION_NUM_TYPES];
 };
 
+/*
+ * UID/GID attributes
+ */
+struct _posix_spawn_posix_cred_info {
+       uint32_t pspci_flags;    /* spawn persona flags */
+       uid_t    pspci_uid;      /* alternate posix/unix UID  */
+       gid_t    pspci_gid;      /* alternate posix/unix GID */
+       uint32_t pspci_ngroups;  /* alternate advisory groups */
+       gid_t    pspci_groups[NGROUPS];
+       uid_t    pspci_gmuid;    /* group membership UID */
+       char     pspci_login[MAXLOGNAME + 1];
+};
+
+#define POSIX_SPAWN_POSIX_CRED_UID          0x00010000
+#define POSIX_SPAWN_POSIX_CRED_GID          0x00020000
+#define POSIX_SPAWN_POSIX_CRED_GROUPS       0x00040000
+#define POSIX_SPAWN_POSIX_CRED_LOGIN        0x00080000
+
 /*
  * Persona attributes
  */
@@ -163,18 +182,18 @@ struct _posix_spawn_persona_info {
        uid_t    pspi_gmuid;    /* group membership UID */
 };
 
-#define POSIX_SPAWN_PERSONA_FLAGS_NONE     0x0
-#define POSIX_SPAWN_PERSONA_FLAGS_OVERRIDE 0x1
-#define POSIX_SPAWN_PERSONA_FLAGS_VERIFY   0x2
+#define POSIX_SPAWN_PERSONA_FLAGS_NONE      0x0
+#define POSIX_SPAWN_PERSONA_FLAGS_OVERRIDE  0x1
+#define POSIX_SPAWN_PERSONA_FLAGS_VERIFY    0x2
 
 #define POSIX_SPAWN_PERSONA_ALL_FLAGS \
        (POSIX_SPAWN_PERSONA_FLAGS_OVERRIDE \
         | POSIX_SPAWN_PERSONA_FLAGS_VERIFY \
        )
 
-#define POSIX_SPAWN_PERSONA_UID           0x00010000
-#define POSIX_SPAWN_PERSONA_GID           0x00020000
-#define POSIX_SPAWN_PERSONA_GROUPS        0x00040000
+#define POSIX_SPAWN_PERSONA_UID             POSIX_SPAWN_POSIX_CRED_UID
+#define POSIX_SPAWN_PERSONA_GID             POSIX_SPAWN_POSIX_CRED_GID
+#define POSIX_SPAWN_PERSONA_GROUPS          POSIX_SPAWN_POSIX_CRED_GROUPS
 
 
 /*
@@ -221,6 +240,7 @@ typedef struct _posix_spawnattr {
        _posix_spawn_mac_policy_extensions_t psa_mac_extensions; /* MAC policy-specific extensions. */
        struct _posix_spawn_coalition_info *psa_coalition_info;  /* coalition info */
        struct _posix_spawn_persona_info   *psa_persona_info;    /* spawn new process into given persona */
+       struct _posix_spawn_posix_cred_info *psa_posix_cred_info; /* posix creds: uid/gid/groups */
 } *_posix_spawnattr_t;
 
 /*
@@ -239,6 +259,20 @@ typedef struct _posix_spawnattr {
 #define POSIX_SPAWN_JETSAM_MEMLIMIT_ACTIVE_FATAL        0x04  /* if set, limit is fatal when the process is active   */
 #define POSIX_SPAWN_JETSAM_MEMLIMIT_INACTIVE_FATAL      0x08  /* if set, limit is fatal when the process is inactive */
 
+
+/*
+ * Flags set based on posix_spawnattr_set_jetsam_ttr_np().
+ * Indicate relaunch behavior of process when jetsammed
+ */
+/* Mask and bucket counts for relaunch behavior */
+#define POSIX_SPAWN_JETSAM_RELAUNCH_BEHAVIOR_BUCKETS    (0x3)
+#define POSIX_SPAWN_JETSAM_RELAUNCH_BEHAVIOR_MASK       (0x30)
+
+/* Actual buckets based on behavior data */
+#define POSIX_SPAWN_JETSAM_RELAUNCH_BEHAVIOR_HIGH       (0x30)
+#define POSIX_SPAWN_JETSAM_RELAUNCH_BEHAVIOR_MED        (0x20)
+#define POSIX_SPAWN_JETSAM_RELAUNCH_BEHAVIOR_LOW        (0x10)
+
 /*
  * Deprecated posix_spawn psa_flags values
  *
@@ -271,7 +305,6 @@ typedef struct _posix_spawnattr {
  * posix_spawn psa_apptype process type settings.
  * when POSIX_SPAWN_PROC_TYPE is set, old psa_apptype bits are ignored
  */
-
 #define POSIX_SPAWN_PROCESS_TYPE_NORMAL             0x00000000
 #define POSIX_SPAWN_PROCESS_TYPE_DEFAULT            POSIX_SPAWN_PROCESS_TYPE_NORMAL
 
@@ -285,12 +318,15 @@ typedef struct _posix_spawnattr {
 #define POSIX_SPAWN_PROC_TYPE_DAEMON_BACKGROUND     0x00000500
 #define POSIX_SPAWN_PROC_TYPE_DAEMON_ADAPTIVE       0x00000600
 
+#define POSIX_SPAWN_PROC_TYPE_DRIVER                0x00000700
+
 #define POSIX_SPAWN_PROC_CLAMP_NONE                 0x00000000
 #define POSIX_SPAWN_PROC_CLAMP_UTILITY              0x00000001
 #define POSIX_SPAWN_PROC_CLAMP_BACKGROUND           0x00000002
 #define POSIX_SPAWN_PROC_CLAMP_MAINTENANCE          0x00000003
 #define POSIX_SPAWN_PROC_CLAMP_LAST                 0x00000004
 
+#define POSIX_SPAWN_ENTITLEMENT_DRIVER "com.apple.private.spawn-driver"
 /* Setting to indicate no change to darwin role */
 #define POSIX_SPAWN_DARWIN_ROLE_NONE                0x00000000
 /* Other possible values are specified by PRIO_DARWIN_ROLE in sys/resource.h */
@@ -302,7 +338,10 @@ typedef enum {
        PSFA_OPEN = 0,
        PSFA_CLOSE = 1,
        PSFA_DUP2 = 2,
-       PSFA_INHERIT = 3
+       PSFA_INHERIT = 3,
+       PSFA_FILEPORT_DUP2 = 4,
+       PSFA_CHDIR = 5,
+       PSFA_FCHDIR = 6
 } psfa_t;
 
 
@@ -317,17 +356,26 @@ typedef enum {
  *             a variable sized vector list to save space (i.e. a separate
  *             string area, allocation of least amount of path buffer per
  *             open action, etc.).
- *
- * XXX:                Currently overloading psfao_oflag for PSFA_DUP2
  */
 typedef struct _psfa_action {
-       psfa_t  psfaa_type;                     /* file action type */
-       int     psfaa_filedes;                  /* fd to operate on */
-       struct _psfaa_open {
-               int     psfao_oflag;            /* open flags to use */
-               mode_t  psfao_mode;             /* mode for open */
-               char    psfao_path[PATH_MAX];   /* path to open */
-       } psfaa_openargs;
+       psfa_t  psfaa_type;                         /* file action type */
+       union {
+               int psfaa_filedes;                  /* fd to operate on */
+               mach_port_name_t psfaa_fileport;    /* fileport to operate on */
+       };
+       union {
+               struct _psfaa_open {
+                       int     psfao_oflag;            /* open flags to use */
+                       mode_t  psfao_mode;             /* mode for open */
+                       char    psfao_path[PATH_MAX];   /* path to open */
+               } psfaa_openargs;
+               struct {
+                       int psfad_newfiledes;           /* new file descriptor to use */
+               } psfaa_dup2args;
+               struct {
+                       char    psfac_path[PATH_MAX];   /* path to chdir */
+               } psfaa_chdirargs;
+       };
 } _psfa_action_t;
 
 
@@ -393,6 +441,9 @@ struct _posix_spawn_args_desc {
 
        __darwin_size_t persona_info_size;
        struct _posix_spawn_persona_info   *persona_info;
+
+       __darwin_size_t posix_cred_info_size;
+       struct _posix_spawn_posix_cred_info *posix_cred_info;
 };
 
 #ifdef KERNEL
@@ -404,33 +455,37 @@ struct _posix_spawn_args_desc {
 #endif
 
 struct user32__posix_spawn_args_desc {
-       uint32_t                attr_size;      /* size of attributes block */
-       uint32_t                attrp;          /* pointer to block */
+       uint32_t        attr_size;              /* size of attributes block */
+       uint32_t        attrp;                  /* pointer to block */
        uint32_t        file_actions_size;      /* size of file actions block */
-       uint32_t                file_actions;   /* pointer to block */
+       uint32_t        file_actions;           /* pointer to block */
        uint32_t        port_actions_size;      /* size of port actions block */
-       uint32_t                port_actions;   /* pointer to block */
+       uint32_t        port_actions;           /* pointer to block */
        uint32_t        mac_extensions_size;
        uint32_t        mac_extensions;
        uint32_t        coal_info_size;
        uint32_t        coal_info;
        uint32_t        persona_info_size;
        uint32_t        persona_info;
+       uint32_t        posix_cred_info_size;
+       uint32_t        posix_cred_info;
 };
 
 struct user__posix_spawn_args_desc {
-       user_size_t             attr_size;      /* size of attributes block */
-       user_addr_t             attrp;          /* pointer to block */
+       user_size_t     attr_size;              /* size of attributes block */
+       user_addr_t     attrp;                  /* pointer to block */
        user_size_t     file_actions_size;      /* size of file actions block */
-       user_addr_t             file_actions;   /* pointer to block */
+       user_addr_t     file_actions;           /* pointer to block */
        user_size_t     port_actions_size;      /* size of port actions block */
-       user_addr_t             port_actions;   /* pointer to block */
+       user_addr_t     port_actions;           /* pointer to block */
        user_size_t     mac_extensions_size;    /* size of MAC-specific attrs. */
        user_addr_t     mac_extensions;         /* pointer to block */
        user_size_t     coal_info_size;
        user_addr_t     coal_info;
        user_size_t     persona_info_size;
        user_addr_t     persona_info;
+       user_size_t     posix_cred_info_size;
+       user_addr_t     posix_cred_info;
 };