source: rtems/cpukit/include/rtems/userenv.h @ e97806a

5
Last change on this file since e97806a was b8bd90f6, checked in by Sebastian Huber <sebastian.huber@…>, on 11/17/14 at 08:01:53

Add supplementary groups to user environment

  • Property mode set to 100644
File size: 4.4 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup LibIOEnv
5 * @brief User Environment Support
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2011.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  Modifications to support reference counting in the file system are
13 *  Copyright (c) 2012 embedded brains GmbH.
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.rtems.org/license/LICENSE.
18 */
19
20#ifndef _RTEMS_USERENV_H
21#define _RTEMS_USERENV_H
22
23/*
24 * According to IEEE Std 1003.1-2001,
25 * limits.h is supposed to provide _POSIX_LOGIN_NAME_MAX
26 * XXX: We do not rely on this.
27 */
28#include <sys/param.h>
29#include <limits.h>
30
31#include <rtems.h>
32#include <rtems/fs.h>
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38/**
39 * @defgroup LibIOEnv User Environment
40 *
41 * @ingroup LibIO
42 *
43 * @brief Provides a POSIX like user environment for tasks.
44 */
45/**@{**/
46
47#ifndef LOGIN_NAME_MAX
48  #ifdef _POSIX_LOGIN_NAME_MAX
49    #define LOGIN_NAME_MAX _POSIX_LOGIN_NAME_MAX
50  #else
51    /* Fallback */
52    #define LOGIN_NAME_MAX 9
53  #endif
54#endif
55
56/**
57 * @brief User environment.
58 */
59typedef struct {
60  /**
61   * @brief The anchor directory for relative paths.
62   */
63  rtems_filesystem_global_location_t *current_directory;
64
65  /**
66   * @brief The anchor directory for absolute paths.
67   */
68  rtems_filesystem_global_location_t *root_directory;
69
70  /**
71   * @brief The file mode creation mask.
72   */
73  mode_t umask;
74
75  /**
76   * @brief The real user ID.
77   */
78  uid_t uid;
79
80  /**
81   * @brief The real group ID.
82   */
83  gid_t gid;
84
85  /**
86   * @brief The effective user ID.
87   */
88  uid_t euid;
89
90  /**
91   * @brief The effective group ID.
92   */
93  gid_t egid;
94
95  /**
96   * @brief The login buffer.
97   */
98  char login_buffer[LOGIN_NAME_MAX];
99
100  /**
101   * @brief The process group ID.
102   */
103  pid_t pgrp;
104
105  /**
106   * @brief The count of supplementary group IDs.
107   */
108  size_t ngroups;
109
110  /**
111   * @brief The list of supplementary group IDs.
112   */
113  gid_t groups[NGROUPS];
114} rtems_user_env_t;
115
116extern rtems_user_env_t rtems_global_user_env;
117
118/**
119 * @brief Fetch the pointer to the current user environment.
120 *
121 * If the task has a private user environment the pointer to it will be
122 * returned. Otherwise the pointer to rtems_global_user_env will be returned.
123 */
124rtems_user_env_t * rtems_current_user_env_get(void);
125
126#define rtems_current_user_env rtems_current_user_env_get()
127
128#define rtems_filesystem_current     (rtems_current_user_env->current_directory)
129#define rtems_filesystem_root        (rtems_current_user_env->root_directory)
130#define rtems_filesystem_umask       (rtems_current_user_env->umask)
131
132#define _POSIX_types_Uid             (rtems_current_user_env->uid)
133#define _POSIX_types_Gid             (rtems_current_user_env->gid)
134#define _POSIX_types_Euid            (rtems_current_user_env->euid)
135#define _POSIX_types_Egid            (rtems_current_user_env->egid)
136#define _POSIX_types_Getlogin_buffer (rtems_current_user_env->login_buffer)
137
138/**
139 * @brief Creates a private environment.
140 *
141 * If the task has already a private environment nothing will be changed.  This
142 * function must be called from normal thread context and may block on a mutex.
143 * Thread dispatching is disabled to protect some critical sections.
144 *
145 * The private environment internally uses a POSIX key. The key is added to the
146 * configuration implicitly. But for each thread that uses a private environment
147 * a key value pair has to be configured by the application. If only the global
148 * environment is used there is no need to configure a key value pair.
149 *
150 * @retval RTEMS_SUCCESSFUL Successful operation.
151 * @retval RTEMS_NO_MEMORY Not enough memory.
152 * @retval RTEMS_UNSATISFIED Cloning of the current environment failed.
153 * @retval RTEMS_TOO_MANY Cannot register the private environment.
154 */
155rtems_status_code rtems_libio_set_private_env(void);
156
157/**
158 * @brief Use the global environment.
159 *
160 * A private environment will be released.  This function may be called from
161 * every thread context.  Thread dispatching is disabled to protect the
162 * critical sections.
163 */
164void rtems_libio_use_global_env(void);
165
166/**
167 * @brief Gets the supplementary group IDs using the current user ID and
168 * updates the table of supplementary group IDs in the current user
169 * environment.
170 *
171 * In case of an error, the count of supplementary group IDs is set to zero.
172 */
173void rtems_current_user_env_getgroups(void);
174
175/** @} */
176
177#ifdef __cplusplus
178}
179#endif
180
181#endif
182/* end of include file */
Note: See TracBrowser for help on using the repository browser.