access_vector_t av = get_access_vector("passwd", "chfn");
if (selinux_check_passwd_access(av) != 0) {
- security_context_t user_context;
+# ifdef HAVE_SELINUX_CONTEXT_T
+ security_context_t user_context; /* deprecated */
+# else
+ char *user_context; /* since libselinux >= 3.1 */
+# endif
if (getprevcon(&user_context) < 0)
user_context = NULL;
+
errx(EXIT_FAILURE,
_("%s is not authorized to change "
"the finger info of %s"),
access_vector_t av = get_access_vector("passwd", "chsh");
if (selinux_check_passwd_access(av) != 0) {
- security_context_t user_context;
+# ifdef HAVE_SELINUX_CONTEXT_T
+ security_context_t user_context; /* deprecated */
+# else
+ char *user_context; /* since libselinux >= 3.1 */
+# endif
if (getprevcon(&user_context) < 0)
- user_context =
- (security_context_t) NULL;
+ user_context = NULL;
errx(EXIT_FAILURE,
_("%s is not authorized to change the shell of %s"),
char *failed_tty;
#ifdef HAVE_LIBSELINUX
+# ifdef HAVE_SELINUX_CONTEXT_T
security_context_t context;
+# else
+ char *context;
+# endif
#endif
char *homedir;
char *shell;
break;
case COL_SELINUX:
#ifdef HAVE_LIBSELINUX
- if (ctl->selinux_enabled) {
- /* typedefs and pointers are pure evil */
- security_context_t con = NULL;
- if (getcon(&con) == 0)
- user->context = con;
- }
+ if (!ctl->selinux_enabled || getcon(&user->context) != 0)
+ user->context = NULL;
#endif
break;
case COL_NPROCS:
int setupDefaultContext(char *orig_file)
{
if (is_selinux_enabled() > 0) {
- security_context_t scontext;
+#ifdef HAVE_SELINUX_CONTEXT_T
+ security_context_t scontext = NULL; /* deprecated */
+#else
+ char *scontext = NULL; /* since libselinux >= 3.1 */
+#endif
if (getfilecon(orig_file, &scontext) < 0)
return 1;
if (setfscreatecon(scontext) < 0) {
#ifdef HAVE_LIBSELINUX
if (is_selinux_enabled() > 0) {
- security_context_t scon=NULL;
+# ifdef HAVE_SELINUX_CONTEXT_T
+ security_context_t scon = NULL; /* deprecated */
+# else
+ char *scon = NULL; /* since libselinux >= 3.1 */
+# endif
char *seuser=NULL;
char *level=NULL;
+
if (getseuserbyname("root", &seuser, &level) == 0) {
if (get_default_context_with_level(seuser, level, 0, &scon) == 0) {
if (setexeccon(scon) != 0)
#ifdef HAVE_LIBSELINUX
if (is_selinux_enabled() > 0) {
- security_context_t passwd_context = NULL;
+# ifdef HAVE_SELINUX_CONTEXT_T
+ security_context_t passwd_context = NULL; /* deprecated */
+# else
+ char *passwd_context = NULL; /* since libselinux >= 3.1 */
+# endif
int ret = 0;
if (getfilecon(orig_file, &passwd_context) < 0) {
warnx(_("Can't get context for %s"), orig_file);