| 77 | } |
| 78 | |
| 79 | int |
| 80 | main (int argc, char **argv) |
| 81 | { |
| 82 | char const *specified_mode = NULL; |
| 83 | char const *scontext = NULL; |
| 84 | struct selabel_handle *set_security_context = NULL; |
| 85 | |
| 86 | initialize_main (&argc, &argv); |
| 87 | set_program_name (argv[0]); |
| 88 | setlocale (LC_ALL, ""); |
| 89 | bindtextdomain (PACKAGE, LOCALEDIR); |
| 90 | textdomain (PACKAGE); |
| 91 | |
| 92 | atexit (close_stdout); |
| 93 | |
| 94 | int optc; |
| 95 | while ((optc = getopt_long (argc, argv, "m:Z", longopts, NULL)) != -1) |
| 96 | { |
| 97 | switch (optc) |
| 98 | { |
| 99 | case 'm': |
| 100 | specified_mode = optarg; |
| 101 | break; |
| 102 | case 'Z': |
| 103 | if (is_smack_enabled ()) |
| 104 | { |
| 105 | /* We don't yet support -Z to restore context with SMACK. */ |
| 106 | scontext = optarg; |
| 107 | } |
| 108 | else if (is_selinux_enabled () > 0) |
| 109 | { |
| 110 | if (optarg) |
| 111 | scontext = optarg; |
| 112 | else |
| 113 | { |
| 114 | set_security_context = selabel_open (SELABEL_CTX_FILE, |
| 115 | NULL, 0); |
| 116 | if (! set_security_context) |
| 117 | error (0, errno, _("warning: ignoring --context")); |
| 118 | } |
| 119 | } |
| 120 | else if (optarg) |
| 121 | { |
| 122 | error (0, 0, |
| 123 | _("warning: ignoring --context; " |
| 124 | "it requires an SELinux/SMACK-enabled kernel")); |
| 125 | } |
| 126 | break; |
| 127 | case_GETOPT_HELP_CHAR; |
| 128 | case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); |
| 129 | default: |
| 130 | usage (EXIT_FAILURE); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | if (optind == argc) |
| 135 | { |
| 136 | error (0, 0, _("missing operand")); |
nothing calls this directly
no test coverage detected