]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Create dbs with correct permissions. 4/head
authorDimitri John Ledkov <dimitri.j.ledkov@intel.com>
Fri, 27 Feb 2015 16:26:57 +0000 (16:26 +0000)
committerDimitri John Ledkov <dimitri.j.ledkov@intel.com>
Fri, 27 Feb 2015 17:01:31 +0000 (17:01 +0000)
lib/commonio.c
lib/commonio.h
lib/groupio.c
lib/pwio.c
lib/sgroupio.c
lib/shadowio.c
lib/subordinateio.c

index cc536bf140c7a98dd778784ce43baf085f4f05a4..b1c2771c841d2a52440d50065c8e34df2fee708b 100644 (file)
@@ -968,11 +968,10 @@ int commonio_close (struct commonio_db *db)
        } else {
                /*
                 * Default permissions for new [g]shadow files.
-                * (passwd and group always exist...)
                 */
-               sb.st_mode = 0400;
-               sb.st_uid = 0;
-               sb.st_gid = 0;
+               sb.st_mode = db->st_mode;
+               sb.st_uid = db->st_uid;
+               sb.st_gid = db->st_gid;
        }
 
        snprintf (buf, sizeof buf, "%s+", db->filename);
index 0a316f9c8992f82793611f2aefb31fbd22a8574d..cb4e961678193a4248eb362537ab3629f31dd88f 100644 (file)
@@ -123,6 +123,12 @@ struct commonio_db {
 #ifdef WITH_SELINUX
        /*@null@*/security_context_t scontext;
 #endif
+       /*
+        * Default permissions and owner for newly created data file.
+         */
+       mode_t st_mode;
+       uid_t st_uid;
+       gid_t st_gid;
        /*
         * Head, tail, current position in linked list.
         */
index 2a37bfd9ae37690c0deb00d2db7a62a880e32bf3..3ad4736bbf0cbed57b0806fc1bc4aefbb51fd68c 100644 (file)
@@ -130,6 +130,9 @@ static /*@owned@*/struct commonio_db group_db = {
 #ifdef WITH_SELINUX
        NULL,                   /* scontext */
 #endif
+       0644,                   /* st_mode */
+       0,                      /* st_uid */
+       0,                      /* st_gid */
        NULL,                   /* head */
        NULL,                   /* tail */
        NULL,                   /* cursor */
index 793c2e5a96776f108e5d937c7695d63b812efcb3..7ee85377225f1c280793e7f2ecd45e33ab92336b 100644 (file)
@@ -105,6 +105,9 @@ static struct commonio_db passwd_db = {
 #ifdef WITH_SELINUX
        NULL,                   /* scontext */
 #endif
+       0644,                   /* st_mode */
+       0,                      /* st_uid */
+       0,                      /* st_gid */
        NULL,                   /* head */
        NULL,                   /* tail */
        NULL,                   /* cursor */
index b497cd65db57cddbd02faef0fac31d9e8d3a3970..f2685779a12bfa3c7e0ff1891171fac0c6391478 100644 (file)
@@ -228,6 +228,9 @@ static struct commonio_db gshadow_db = {
 #ifdef WITH_SELINUX
        NULL,                   /* scontext */
 #endif
+       0400,                   /* st_mode */
+       0,                      /* st_uid */
+       0,                      /* st_gid */
        NULL,                   /* head */
        NULL,                   /* tail */
        NULL,                   /* cursor */
index 1fb1bbab9ad1b6acb60b81680a3ae234fbf37542..6e44ab24d69c9b2163ca15ecebfc0d092ec61463 100644 (file)
@@ -104,6 +104,9 @@ static struct commonio_db shadow_db = {
 #ifdef WITH_SELINUX
        NULL,                   /* scontext */
 #endif                         /* WITH_SELINUX */
+       0400,                   /* st_mode */
+       0,                      /* st_uid */
+       0,                      /* st_gid */
        NULL,                   /* head */
        NULL,                   /* tail */
        NULL,                   /* cursor */
index 88cc58176e96de865843383c96b75af83069d592..0d64a91480cb250e187e9e28f81dc06979687f35 100644 (file)
@@ -541,6 +541,9 @@ static struct commonio_db subordinate_uid_db = {
 #ifdef WITH_SELINUX
        NULL,                   /* scontext */
 #endif
+       0644,                   /* st_mode */
+       0,                      /* st_uid */
+       0,                      /* st_gid */
        NULL,                   /* head */
        NULL,                   /* tail */
        NULL,                   /* cursor */
@@ -619,6 +622,9 @@ static struct commonio_db subordinate_gid_db = {
 #ifdef WITH_SELINUX
        NULL,                   /* scontext */
 #endif
+       0644,                   /* st_mode */
+       0,                      /* st_uid */
+       0,                      /* st_gid */
        NULL,                   /* head */
        NULL,                   /* tail */
        NULL,                   /* cursor */