Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 131237 Details for
Bug 192682
New "checkdir" applet for baselayout 2
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Checkdir patch v2, some corrections/improvements
checkdir_baselayout2_v2.patch (text/plain), 4.06 KB, created by
Renato Caldas
on 2007-09-18 19:13:15 UTC
(
hide
)
Description:
Checkdir patch v2, some corrections/improvements
Filename:
MIME Type:
Creator:
Renato Caldas
Created:
2007-09-18 19:13:15 UTC
Size:
4.06 KB
patch
obsolete
>diff -uNr baselayout-2.0.0_rc4/src/builtins.h baselayout-2.0.0_rc4_new/src/builtins.h >--- baselayout-2.0.0_rc4/src/builtins.h 2007-08-04 16:05:12.000000000 +0100 >+++ baselayout-2.0.0_rc4_new/src/builtins.h 2007-09-17 10:41:14.000000000 +0100 >@@ -15,4 +15,5 @@ > int rc_update (int argc, char **argv); > int runscript (int argc, char **argv); > int start_stop_daemon (int argc, char **argv); >+int checkdir (int argc, char **argv); > >diff -uNr baselayout-2.0.0_rc4/src/checkdir.c baselayout-2.0.0_rc4_new/src/checkdir.c >--- baselayout-2.0.0_rc4/src/checkdir.c 1970-01-01 01:00:00.000000000 +0100 >+++ baselayout-2.0.0_rc4_new/src/checkdir.c 2007-09-18 18:53:31.000000000 +0100 >@@ -0,0 +1,119 @@ >+/* >+ checkdir.c >+ Checks for the existance of a directory and creates it >+ if necessary. It can also correct its ownership. >+ >+ Copyright 2007 Gentoo Foundation >+ */ >+ >+#define APPLET "checkdir" >+ >+#include <errno.h> >+#include <getopt.h> >+#include <stdio.h> >+#include <stdlib.h> >+#include <string.h> >+#include <unistd.h> >+#include <sys/stat.h> >+#include <sys/types.h> >+#include <pwd.h> >+#include <grp.h> >+ >+#include "builtins.h" >+#include "einfo.h" >+ >+#include "_usage.h" >+#define getoptstring "d:u:g:m:" getoptstring_COMMON >+static struct option longopts[] = { >+ { "user", 1, NULL, 'u'}, >+ { "group", 1, NULL, 'g'}, >+ { "mode", 1, NULL, 'm'}, >+ longopts_COMMON >+ { NULL, 0, NULL, 0} >+}; >+#include "_usage.c" >+ >+static char *progname; >+ >+static int do_check(char *path, uid_t uid, gid_t gid) >+{ >+ struct stat dirstat; >+ >+ /* create dir, if it doesn't exist */ >+ if (mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH )) >+ if (errno != EEXIST) >+ eerrorx("%s: mkdir: %s", progname, strerror(errno)); >+ else >+ einfo("Created directory %s", path); >+ >+ if (stat(path, &dirstat)) >+ eerrorx("%s: %s", progname, strerror(errno)); >+ >+ if (dirstat.st_uid != uid || dirstat.st_gid != gid) { >+ einfo("Correcting directory ownership."); >+ if (chown(path, uid, gid)) >+ eerrorx("%s: chown: %s", progname, strerror(errno)); >+ } >+} >+ >+int checkdir (int argc, char **argv) >+{ >+ int opt; >+ char *user = NULL; >+ char *group = NULL; >+ uid_t uid = getuid(); >+ gid_t gid = getgid(); >+ >+ progname = argv[0]; >+ >+ while ((opt = getopt_long (argc, argv, getoptstring, >+ longopts, (int *) 0)) != -1) { >+ switch (opt) { >+ case 'u': >+ user = strsep (&optarg, ":"); >+ if (user[0] == '\0') >+ user = NULL; >+ group = optarg; >+ break; >+ >+ case 'g': >+ group = optarg; >+ break; >+ >+ case_RC_COMMON_GETOPT >+ } >+ } >+ >+ if (user != NULL) { >+ struct passwd *pwd; >+ char *endptr; >+ >+ uid = strtol(user, &endptr, 10); >+ if (endptr[0] != '\0') { >+ if ( (pwd = getpwnam(user)) == NULL) >+ eerrorx("%s: Can't set user: %s", argv[0], >+ user); >+ uid = pwd->pw_uid; >+ } >+ } >+ >+ if (group != NULL) { >+ struct group *grp; >+ char *endptr; >+ >+ gid = strtol(group, &endptr, 10); >+ if (endptr[0] != '\0') { >+ if ( (grp = getgrnam(group)) == NULL) >+ eerrorx("%s: Can't set group: %s", argv[0], >+ group); >+ gid = grp->gr_gid; >+ } >+ } >+ >+ while (optind < argc) { >+ do_check(argv[optind], uid, gid); >+ optind++; >+ } >+ >+ exit(EXIT_SUCCESS); >+} >diff -uNr baselayout-2.0.0_rc4/src/Makefile baselayout-2.0.0_rc4_new/src/Makefile >--- baselayout-2.0.0_rc4/src/Makefile 2007-08-16 17:53:20.000000000 +0100 >+++ baselayout-2.0.0_rc4_new/src/Makefile 2007-09-17 10:41:14.000000000 +0100 >@@ -34,7 +34,7 @@ > > RCOBJS = env-update.o fstabinfo.o mountinfo.o \ > rc-depend.o rc-plugin.o rc-status.o rc-update.o runscript.o \ >- start-stop-daemon.o >+ start-stop-daemon.o checkdir.o > > LIB_TARGETS = $(LIBEINFOSO) $(LIBRCSO) > SBIN_TARGETS = rc >diff -uNr baselayout-2.0.0_rc4/src/rc.c baselayout-2.0.0_rc4_new/src/rc.c >--- baselayout-2.0.0_rc4/src/rc.c 2007-08-28 17:28:33.000000000 +0100 >+++ baselayout-2.0.0_rc4_new/src/rc.c 2007-09-17 10:41:14.000000000 +0100 >@@ -758,6 +758,8 @@ > exit (runscript (argc, argv)); > else if (strcmp (applet, "start-stop-daemon") == 0) > exit (start_stop_daemon (argc, argv)); >+ else if (strcmp (applet, "checkdir") == 0) >+ exit (checkdir (argc, argv)); > > argc--; > argv++;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 192682
:
131042
|
131237
|
131238