Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 131042 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]
The patch against baselayout 2
checkdir_baselayout2.patch (text/plain), 3.80 KB, created by
Renato Caldas
on 2007-09-16 12:39:20 UTC
(
hide
)
Description:
The patch against baselayout 2
Filename:
MIME Type:
Creator:
Renato Caldas
Created:
2007-09-16 12:39:20 UTC
Size:
3.80 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-09 12:48:46.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-16 13:30:21.000000000 +0100 >@@ -0,0 +1,122 @@ >+/* >+ 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:o:" getoptstring_COMMON >+static struct option longopts[] = { >+ { "directory", 1, NULL, 'd'}, >+ { "chown", 1, NULL, 'o'}, >+ longopts_COMMON >+ { NULL, 0, NULL, 0} >+}; >+#include "_usage.c" >+ >+int checkdir (int argc, char **argv) >+{ >+ int opt; >+ char *path = NULL; >+ struct stat dirstat; >+ >+ char *owner = NULL; >+ char *group = NULL; >+ >+ uid_t uid = getuid(); >+ gid_t gid = getgid(); >+ >+ while ((opt = getopt_long (argc, argv, getoptstring, >+ longopts, (int *) 0)) != -1) >+ { >+ switch (opt) { >+ case 'd': >+ path = optarg; >+ break; >+ >+ case 'o': >+ owner = strsep (&optarg, ":"); >+ if (owner[0] == '\0') >+ { >+ owner = NULL; >+ } >+ group = optarg; >+ break; >+ >+ case_RC_COMMON_GETOPT >+ } >+ >+ } >+ >+ if (path == NULL) >+ { >+ exit(EXIT_FAILURE); >+ } >+ >+ /* 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", argv[0], strerror(errno)); >+ } >+ } >+ else >+ { >+ einfo("Created directory %s", path); >+ } >+ >+ if (stat(path, &dirstat)) >+ { >+ eerrorx("%s: %s", argv[0], strerror(errno)); >+ } >+ >+ if (owner != NULL) >+ { >+ struct passwd *pwd; >+ if ( (pwd = getpwnam(owner)) == NULL) >+ { >+ eerrorx("%s: Can't set owner: %s", argv[0], owner); >+ } >+ uid = pwd->pw_uid; >+ } >+ >+ if (group != NULL) >+ { >+ struct group *grp; >+ if ( (grp = getgrnam(group)) == NULL) >+ { >+ eerrorx("%s: Can't set group: %s", argv[0], group); >+ } >+ gid = grp->gr_gid; >+ } >+ >+ if (dirstat.st_uid != uid || dirstat.st_gid != gid) >+ { >+ einfo("Correcting directory ownership."); >+ if (chown(path, uid, gid)) >+ { >+ eerrorx("%s: chown: %s", argv[0], strerror(errno)); >+ } >+ } >+ >+ 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-09 12:52:31.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-09 12:54:40.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