25 |
* |
* |
26 |
* Port to busybox: KaiGai Kohei <kaigai@kaigai.gr.jp> |
* Port to busybox: KaiGai Kohei <kaigai@kaigai.gr.jp> |
27 |
* - based on coreutils-5.97 (in Fedora Core 6) |
* - based on coreutils-5.97 (in Fedora Core 6) |
28 |
|
* |
29 |
|
* Licensed under GPLv2, see file LICENSE in this tarball for details. |
30 |
*/ |
*/ |
31 |
#include <getopt.h> |
#include <getopt.h> |
32 |
#include <selinux/context.h> |
#include <selinux/context.h> |
41 |
security_context_t cur_context; |
security_context_t cur_context; |
42 |
|
|
43 |
if (getcon(&cur_context)) |
if (getcon(&cur_context)) |
44 |
bb_error_msg_and_die("cannot get current context"); |
bb_error_msg_and_die("can't get current context"); |
45 |
|
|
46 |
if (compute_trans) { |
if (compute_trans) { |
47 |
security_context_t file_context, new_context; |
security_context_t file_context, new_context; |
48 |
|
|
49 |
if (getfilecon(command, &file_context) < 0) |
if (getfilecon(command, &file_context) < 0) |
50 |
bb_error_msg_and_die("cannot retrieve attributes of '%s'", |
bb_error_msg_and_die("can't retrieve attributes of '%s'", |
51 |
command); |
command); |
52 |
if (security_compute_create(cur_context, file_context, |
if (security_compute_create(cur_context, file_context, |
53 |
SECCLASS_PROCESS, &new_context)) |
SECCLASS_PROCESS, &new_context)) |
129 |
context_str(con)); |
context_str(con)); |
130 |
|
|
131 |
if (setexeccon(context_str(con))) |
if (setexeccon(context_str(con))) |
132 |
bb_error_msg_and_die("cannot set up security context '%s'", |
bb_error_msg_and_die("can't set up security context '%s'", |
133 |
context_str(con)); |
context_str(con)); |
134 |
|
|
135 |
execvp(argv[0], argv); |
execvp(argv[0], argv); |
136 |
|
|
137 |
bb_perror_msg_and_die("cannot execute '%s'", argv[0]); |
bb_perror_msg_and_die("can't execute '%s'", argv[0]); |
138 |
} |
} |