maxwen | 27116ba | 2015-08-14 21:41:28 +0200 | [diff] [blame] | 1 | #include <libbb.h> |
| 2 | #include <selinux/selinux.h> |
| 3 | |
| 4 | /* create a new context with user name (may be unsafe) */ |
| 5 | int get_default_context(const char* user, |
| 6 | const char* fromcon UNUSED_PARAM, |
| 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 */ |
| 22 | int security_compute_relabel(const char *scon UNUSED_PARAM, |
| 23 | const char *tcon, |
| 24 | security_class_t tclass UNUSED_PARAM, |
| 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. */ |
| 36 | int selinux_check_passwd_access(access_vector_t requested UNUSED_PARAM) |
| 37 | { |
| 38 | return 0; |
| 39 | } |