From: Daniel J Walsh <dwalsh@redhat.com>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: "Todd C. Miller" <tmiller@tresys.com>,
selinux@tycho.nsa.gov, jbrindle@tresys.com
Subject: Re: [patch 0/4] libsemanage: genhomedircon regressions
Date: Fri, 28 Sep 2007 11:06:06 -0400 [thread overview]
Message-ID: <46FD185E.4050201@redhat.com> (raw)
In-Reply-To: <1190987704.22078.7.camel@moss-spartans.epoch.ncsc.mil>
[-- Attachment #1: Type: text/plain, Size: 2203 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Stephen Smalley wrote:
> On Fri, 2007-09-28 at 09:51 -0400, Stephen Smalley wrote:
>> On Fri, 2007-09-28 at 09:58 -0400, Daniel J Walsh wrote:
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> Stephen Smalley wrote:
>>>> On Fri, 2007-09-28 at 09:36 -0400, Stephen Smalley wrote:
>>>>> On Thu, 2007-09-27 at 16:07 -0400, Todd C. Miller wrote:
>>>>>> This patch set fixes several regressions found in the new genhomedircon
>>>>>> replacement. I've broken things up into their logical parts for easy
>>>>>> reading. I've also included Dan's do_rebuild_file_context and swigify
>>>>>> patches as a 4th diff. If we want to treat that completely separately
>>>>>> we can.
>>>>> patch 1/4 yielded a non-buildable tree, so I applied 1/4 and 3/4
>>>>> together as a single commit.
>>>>>
>>>>> 2/4 applied as a bug fix independent of the others.
>>>>>
>>>>> 4/4 dropped except for Makefile swigify target.
>>>>>
>>>>> libsemanage 2.0.10.
>>>> Looking again at the output, the order differs - the libsemanage
>>>> genhomedircon puts the specific user entries first and then the
>>>> generic /home entries, which seems wrong given that later entries take
>>>> precedence for matchpathcon. genhomedircon script does the opposite.
>>>>
>>> It should be alright because of the specificity is greater.
>>>
>>> /home/dwalsh/.*
>>>
>>> vs
>>>
>>> /home/.*
>> I don't think that works out in all cases, e.g.
>> matchpathcon /home/xguest/.ssh yields a different result.
>
> Old order (genhomedircon script output):
> # matchpathcon /home/xguest/.ssh
> /home/xguest/.ssh xguest_u:object_r:xguest_home_t
>
> New order (latest libsemanage):
> # matchpathcon /home/xguest/.ssh
> /home/xguest/.ssh system_u:object_r:user_home_ssh_t
>
> Which did you want it to be?
>
Yes you are right.
The problem is we need to find the failsafe account before writing the
general account.
How about this patch.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFG/RhdrlYvE4MpobMRAqTmAKDCE7++pT4Cyia9otRgxVKDGliybQCeORmj
JjDY5P3SDBwohQRC5uPJwNU=
=HkqG
-----END PGP SIGNATURE-----
[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 3680 bytes --]
diff --exclude-from=exclude -N -u -r nsalibsemanage/src/genhomedircon.c libsemanage-2.0.10/src/genhomedircon.c
--- nsalibsemanage/src/genhomedircon.c 2007-09-28 09:48:57.000000000 -0400
+++ libsemanage-2.0.10/src/genhomedircon.c 2007-09-28 10:59:54.000000000 -0400
@@ -575,10 +575,8 @@
return STATUS_SUCCESS;
}
-static genhomedircon_user_entry_t *get_users(genhomedircon_settings_t * s,
- int *errors)
+static int setup_fallback_user(genhomedircon_settings_t * s)
{
- genhomedircon_user_entry_t *head = NULL;
semanage_seuser_t **seuser_list = NULL;
unsigned int nseusers = 0;
semanage_user_t **user_list = NULL;
@@ -587,17 +585,13 @@
const char *name = NULL;
const char *seuname = NULL;
const char *prefix = NULL;
- struct passwd pwstorage, *pwent = NULL;
unsigned int i;
- long rbuflen;
- char *rbuf = NULL;
int retval;
-
- *errors = 0;
+ int errors = 0;
retval = semanage_seuser_list(s->h_semanage, &seuser_list, &nseusers);
if (retval < 0 || (nseusers < 1)) {
/* if there are no users, this function can't do any other work */
- return NULL;
+ return errors;
}
if (semanage_user_list(s->h_semanage, &user_list, &nusers) < 0) {
@@ -607,14 +601,6 @@
qsort(user_list, nusers, sizeof(semanage_user_t *),
(int (*)(const void *, const void *))&user_sort_func);
- /* Allocate space for the getpwnam_r buffer */
- rbuflen = sysconf(_SC_GETPW_R_SIZE_MAX);
- if (rbuflen <= 0)
- goto cleanup;
- rbuf = malloc(rbuflen);
- if (rbuf == NULL)
- goto cleanup;
-
for (i = 0; i < nseusers; i++) {
name = semanage_seuser_get_name(seuser_list[i]);
if (strcmp(name, DEFAULT_LOGIN) == 0) {
@@ -630,14 +616,54 @@
} else {
prefix = name;
}
-
if (set_fallback_user(s, seuname, prefix) != 0) {
- *errors = STATUS_ERR;
- goto cleanup;
+ errors = STATUS_ERR;
}
break;
}
}
+ return errors;
+}
+
+static genhomedircon_user_entry_t *get_users(genhomedircon_settings_t * s,
+ int *errors)
+{
+ genhomedircon_user_entry_t *head = NULL;
+ semanage_seuser_t **seuser_list = NULL;
+ unsigned int nseusers = 0;
+ semanage_user_t **user_list = NULL;
+ unsigned int nusers = 0;
+ semanage_user_t **u = NULL;
+ const char *name = NULL;
+ const char *seuname = NULL;
+ const char *prefix = NULL;
+ struct passwd pwstorage, *pwent = NULL;
+ unsigned int i;
+ long rbuflen;
+ char *rbuf = NULL;
+ int retval;
+
+ *errors = 0;
+ retval = semanage_seuser_list(s->h_semanage, &seuser_list, &nseusers);
+ if (retval < 0 || (nseusers < 1)) {
+ /* if there are no users, this function can't do any other work */
+ return NULL;
+ }
+
+ if (semanage_user_list(s->h_semanage, &user_list, &nusers) < 0) {
+ nusers = 0;
+ }
+
+ qsort(user_list, nusers, sizeof(semanage_user_t *),
+ (int (*)(const void *, const void *))&user_sort_func);
+
+ /* Allocate space for the getpwnam_r buffer */
+ rbuflen = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (rbuflen <= 0)
+ goto cleanup;
+ rbuf = malloc(rbuflen);
+ if (rbuf == NULL)
+ goto cleanup;
for (i = 0; i < nseusers; i++) {
seuname = semanage_seuser_get_sename(seuser_list[i]);
@@ -769,12 +795,10 @@
goto done;
}
- if (write_gen_home_dir_context(s, out, user_context_tpl,
- homedir_context_tpl) != STATUS_SUCCESS) {
+ if (setup_fallback_user(s) != 0) {
retval = STATUS_ERR;
goto done;
}
-
for (h = homedirs; h; h = h->next) {
Ustr *temp = ustr_dup_cstr(h->data);
@@ -811,6 +835,12 @@
goto done;
}
+ if (write_gen_home_dir_context(s, out, user_context_tpl,
+ homedir_context_tpl) != STATUS_SUCCESS) {
+ retval = STATUS_ERR;
+ goto done;
+ }
+
done:
/* Cleanup */
semanage_list_destroy(&homedirs);
[-- Attachment #3: diff.sig --]
[-- Type: application/octet-stream, Size: 65 bytes --]
next prev parent reply other threads:[~2007-09-28 15:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-27 20:07 [patch 0/4] libsemanage: genhomedircon regressions Todd C. Miller
2007-09-27 20:07 ` [patch 1/4] libsemanage: validate homedir contexts Todd C. Miller
2007-09-27 20:07 ` [patch 2/4] libsemanage: fix getpw*_r usage Todd C. Miller
2007-09-27 20:07 ` [patch 3/4] libsemanage: update default user Todd C. Miller
2007-09-27 20:07 ` [patch 4/4] libsemanage: rebuild_file_context option Todd C. Miller
2007-09-28 13:36 ` [patch 0/4] libsemanage: genhomedircon regressions Stephen Smalley
2007-09-28 13:44 ` Stephen Smalley
2007-09-28 13:58 ` Daniel J Walsh
2007-09-28 13:51 ` Stephen Smalley
2007-09-28 13:55 ` Stephen Smalley
2007-09-28 15:06 ` Daniel J Walsh [this message]
2007-09-28 14:23 ` Todd Miller
2007-09-28 15:00 ` Todd Miller
2007-09-28 14:59 ` Stephen Smalley
2007-09-28 15:35 ` Joshua Brindle
2007-09-28 16:49 ` Stephen Smalley
2007-09-28 15:15 ` Daniel J Walsh
-- strict thread matches above, loose matches on Subject: below --
2007-09-28 18:04 Todd C. Miller
2007-09-28 18:21 ` Stephen Smalley
2007-10-01 16:31 ` Daniel J Walsh
2007-10-01 17:43 ` Todd Miller
2007-10-05 14:19 ` Stephen Smalley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46FD185E.4050201@redhat.com \
--to=dwalsh@redhat.com \
--cc=jbrindle@tresys.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
--cc=tmiller@tresys.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.