aboutsummaryrefslogtreecommitdiff
path: root/src/rc/checkpath.c
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2015-12-23 14:06:31 -0600
committerWilliam Hubbs <w.d.hubbs@gmail.com>2016-01-12 10:42:14 -0600
commitbf2f40828ee26d3ba9185f29db596ee5d7b9cf61 (patch)
treede1ccdb2fd86e476323908c37ae6588a9ac9ae97 /src/rc/checkpath.c
parentfe485f44339963fdbee143687dcbef2069924bc6 (diff)
Remove multicall binary structure from OpenRC
This eliminates the need for the selinux-specific wrapper scrript we were installing in /lib*/rc/{bin,sbin}.
Diffstat (limited to 'src/rc/checkpath.c')
-rw-r--r--src/rc/checkpath.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index b5a85891..c44ffe8d 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -29,10 +29,10 @@
#include <string.h>
#include <unistd.h>
-#include "builtins.h"
#include "einfo.h"
#include "rc-misc.h"
#include "rc-selinux.h"
+#include "_usage.h"
typedef enum {
inode_unknown = 0,
@@ -41,7 +41,32 @@ typedef enum {
inode_fifo = 3,
} inode_t;
-extern const char *applet;
+const char *applet = NULL;
+const char *extraopts ="path1 [path2] [...]";
+const char *getoptstring = "dDfFpm:o:W" getoptstring_COMMON;
+const struct option longopts[] = {
+ { "directory", 0, NULL, 'd'},
+ { "directory-truncate", 0, NULL, 'D'},
+ { "file", 0, NULL, 'f'},
+ { "file-truncate", 0, NULL, 'F'},
+ { "pipe", 0, NULL, 'p'},
+ { "mode", 1, NULL, 'm'},
+ { "owner", 1, NULL, 'o'},
+ { "writable", 0, NULL, 'W'},
+ longopts_COMMON
+};
+const char * const longopts_help[] = {
+ "Create a directory if not exists",
+ "Create/empty directory",
+ "Create a file if not exists",
+ "Truncate file",
+ "Create a named pipe (FIFO) if not exists",
+ "Mode to check",
+ "Owner to check (user:group)",
+ "Check whether the path is writable or not",
+ longopts_help_COMMON
+};
+const char *usagestring = NULL;
static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
inode_t type, bool trunc, bool chowner, bool selinux_on)
@@ -187,34 +212,7 @@ static int parse_owner(struct passwd **user, struct group **group,
return retval;
}
-#include "_usage.h"
-#define extraopts "path1 [path2] [...]"
-#define getoptstring "dDfFpm:o:W" getoptstring_COMMON
-static const struct option longopts[] = {
- { "directory", 0, NULL, 'd'},
- { "directory-truncate", 0, NULL, 'D'},
- { "file", 0, NULL, 'f'},
- { "file-truncate", 0, NULL, 'F'},
- { "pipe", 0, NULL, 'p'},
- { "mode", 1, NULL, 'm'},
- { "owner", 1, NULL, 'o'},
- { "writable", 0, NULL, 'W'},
- longopts_COMMON
-};
-static const char * const longopts_help[] = {
- "Create a directory if not exists",
- "Create/empty directory",
- "Create a file if not exists",
- "Truncate file",
- "Create a named pipe (FIFO) if not exists",
- "Mode to check",
- "Owner to check (user:group)",
- "Check whether the path is writable or not",
- longopts_help_COMMON
-};
-#include "_usage.c"
-
-int checkpath(int argc, char **argv)
+int main(int argc, char **argv)
{
int opt;
uid_t uid = geteuid();
@@ -229,6 +227,7 @@ int checkpath(int argc, char **argv)
bool writable = false;
bool selinux_on = false;
+ applet = basename_c(argv[0]);
while ((opt = getopt_long(argc, argv, getoptstring,
longopts, (int *) 0)) != -1)
{