All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Brindle <method@manicmethod.com>
To: Daniel J Walsh <dwalsh@redhat.com>
Cc: Chad Sellers <csellers@tresys.com>, SE Linux <selinux@tycho.nsa.gov>
Subject: Re: libsemanage patch
Date: Wed, 16 Sep 2009 11:55:38 -0400	[thread overview]
Message-ID: <4AB10A7A.3050006@manicmethod.com> (raw)
In-Reply-To: <4AB102CE.3070102@manicmethod.com>

[-- Attachment #1: Type: text/plain, Size: 2769 bytes --]



Joshua Brindle wrote:
>
>
> Chad Sellers wrote:
>> On 9/7/09 6:44 AM, "Daniel J Walsh"<dwalsh@redhat.com>  wrote:
>>
>>    
>>> On 09/04/2009 09:56 AM, Joshua Brindle wrote:
>>>      
>>>> Daniel J Walsh wrote:
>>>>        
>>>>> If you have a homedir that ends in '/', genhomedircon gets confused.
>>>>>
>>>>> # useradd -h /home2/dwalsh/ dwalsh
>>>>> # genhomedircon
>>>>>
>>>>> Check out the labeling.  genhomedircon thinks dwalsh is a toplevel
>>>>> home root.
>>>>>
>>>>> We should just get rid of this command...  :^)
>>>>>
>>>>> Patch removes all trailing '/' from homedir.
>>>>>          
>>>>> diff --exclude-from=exclude -N -u -r
>>>>> nsalibsemanage/src/genhomedircon.c libsemanage-2.0.33/src/genhomedircon.c
>>>>> --- nsalibsemanage/src/genhomedircon.c    2008-08-28
>>>>> 09:34:24.000000000 -0400
>>>>> +++ libsemanage-2.0.33/src/genhomedircon.c    2009-07-15
>>>>> 10:32:20.000000000 -0400
>>>>> @@ -304,6 +304,10 @@
>>>>>               continue;
>>>>>           if (!semanage_list_find(shells, pwbuf->pw_shell))
>>>>>               continue;
>>>>> +        int len = strlen(pwbuf->pw_dir) -1;
>>>>> +        for(; len>  0&&  pwbuf->pw_dir[len]=='/'; len--) {
>>>>> +            pwbuf->pw_dir[len]=0;
>>>>> +        }
>>>>>           if (strcmp(pwbuf->pw_dir, "/") == 0)
>>>>>               continue;
>>>>>           if (semanage_str_count(pwbuf->pw_dir, '/')<= 1)
>>>>>          
>>>> Why aren't you just doing:
>>>>
>>>> len = strlen(pwbuf->pwdir);
>>>> if (pwbuf->pwdir[len] == '/')
>>>>      pwbuf->pwdir[len] = '\0';
>>>>
>>>> ?
>>>>
>>>>        
>>> What about /home/dwalsh//////
>>> Which I believe is legal
>>>      
>>>> Also, won't this fail if the homedir is set to '/' ? This check should
>>>> probably go below the strcmp(pwbuf->pw_dir, "/") that is currently below
>>>> it.
>>>>        
>>> Yes good point.
>>>
>>>      
>> I thought it worked fine with '/'. Since the loop condition is len>  0
>> (where len is the index of the last character, not the length of the string,
>> which is a bit confusing and should probably be changed), it would never
>> reset the first character. And don't you want this before the
>> strcmp(pwbuf->pw_dir, "/") in case the path is ///// (which would of course
>> be silly, but I believe is legal anyway)?
>>
>> Chad
>>
>>    
>
> Yep, got it.
>
> Acked-By: Joshua Brindle <method@manicmethod.com>

Sorry, premature ack.

I'm not seeing the expected results here. I added a user with a homedir 
of /home/method///// and the file_contexts.homedirs still has:

/home/method//////.+ staff_u:object_r:user_home_t:s0


Also, you should probably use '\0' rather than 0 when truncating the 
path. And does this get rid of the need of:

                 semanage_rtrim(path, '/');

a few lines below your patch?



[-- Attachment #2: Type: text/html, Size: 3845 bytes --]

  reply	other threads:[~2009-09-16 15:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-15 14:36 libsemanage patch Daniel J Walsh
2009-08-11 21:22 ` Chad Sellers
2009-09-04 13:56 ` Joshua Brindle
2009-09-07 10:44   ` Daniel J Walsh
2009-09-08 16:04     ` Chad Sellers
2009-09-16 15:22       ` Joshua Brindle
2009-09-16 15:55         ` Joshua Brindle [this message]
2009-09-16 17:27         ` Daniel J Walsh
2009-09-16 21:12           ` Joshua Brindle
  -- strict thread matches above, loose matches on Subject: below --
2007-12-03 19:31 Daniel J Walsh
2007-12-03 19:51 ` Todd Miller
2007-12-03 19:53   ` Stephen Smalley
2007-12-03 20:03     ` Todd Miller
2007-12-03 20:08       ` Daniel J Walsh
2007-12-03 20:49     ` Daniel J Walsh
2007-12-05 17:48       ` 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=4AB10A7A.3050006@manicmethod.com \
    --to=method@manicmethod.com \
    --cc=csellers@tresys.com \
    --cc=dwalsh@redhat.com \
    --cc=selinux@tycho.nsa.gov \
    /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.