Tanguy Pruvot | d8482db | 2014-08-01 05:36:56 +0200 | [diff] [blame] | 1 | #include <libbb.h> |
Tanguy Pruvot | 76616e3 | 2014-08-05 10:52:43 +0200 | [diff] [blame] | 2 | #include <selinux/selinux.h> |
| 3 | |
| 4 | /* create a new context with user name (may be unsafe) */ |
Tanguy Pruvot | d8482db | 2014-08-01 05:36:56 +0200 | [diff] [blame] | 5 | int get_default_context(const char* user, |
| 6 | const char* fromcon UNUSED_PARAM, |
Tanguy Pruvot | 76616e3 | 2014-08-05 10:52:43 +0200 | [diff] [blame] | 7 | char ** newcon) |
| 8 | { |
| 9 | char fmt[] = "u:r:%s:s0\0"; |
| 10 | int len = strlen(user) + strlen(fmt); |
| 11 | |
| 12 | *newcon = malloc(len); |
| 13 | if (!(*newcon)) |
| 14 | return -1; |
| 15 | snprintf(*newcon, len, fmt, user); |
| 16 | return 0; |
| 17 | } |
| 18 | |
| 19 | /* Compute a relabeling decision and set *newcon to refer to it. |
| 20 | Caller must free via freecon. |
| 21 | Stub not implemented in bionic, but declared in selinux.h */ |
Tanguy Pruvot | d8482db | 2014-08-01 05:36:56 +0200 | [diff] [blame] | 22 | int security_compute_relabel(const char *scon UNUSED_PARAM, |
| 23 | const char *tcon, |
| 24 | security_class_t tclass UNUSED_PARAM, |
Tanguy Pruvot | 76616e3 | 2014-08-05 10:52:43 +0200 | [diff] [blame] | 25 | char ** newcon) |
| 26 | { |
| 27 | if (tcon) |
| 28 | *newcon = strdup(tcon); |
| 29 | if (!(*newcon)) |
| 30 | return -1; |
| 31 | return 0; |
| 32 | } |
| 33 | |
| 34 | /* Check a permission in the passwd class. |
| 35 | Return 0 if granted or -1 otherwise. */ |
Tanguy Pruvot | d8482db | 2014-08-01 05:36:56 +0200 | [diff] [blame] | 36 | int selinux_check_passwd_access(access_vector_t requested UNUSED_PARAM) |
Tanguy Pruvot | 76616e3 | 2014-08-05 10:52:43 +0200 | [diff] [blame] | 37 | { |
| 38 | return 0; |
Tanguy Pruvot | d8482db | 2014-08-01 05:36:56 +0200 | [diff] [blame] | 39 | } |