All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rahul Sandhu" <nvraxn@gmail.com>
To: <nvraxn@gmail.com>
Cc: <bill.c.roberts@gmail.com>, <selinux@vger.kernel.org>
Subject: Re: [PATCH] libsemanage: define basename macro for non-glibc systems
Date: Fri, 21 Feb 2025 09:03:12 +0000	[thread overview]
Message-ID: <D7Y03RIRQTEH.1SUBF6LGYYEM6@gmail.com> (raw)
In-Reply-To: <D7XW1Q3407I9.2LRX5QH5BAHGX@gmail.com>

In regards to this:

> There are two ways you could approach this:
> 1. If you wanted to do an implementation, I would add it to
> utilities.c/h and call it something other than basename so we don't
> get any odd issues with it choosing the one from the headers over the
> macro. Perhaps libsemange_basename(). On glibc systems this would just
> call basename directly and on non-glibc systems do the implementation
> with your own logic.
> 2. Just copy the path into a modifiable buffer on non-glibc systems
>
> I would do both approaches. Create a utility routine that calls
> basename for glibc and for non-glibc just copies it to a modifiable
> buffer and then calls basename over rolling our own and the bugs
> associated with it, also add a unit test for this. This would keep the
> logic in one place and be dirt simple.

It appears that glibc's basename(3) has a different behaviour to the
version of basename(3) defined in posix. From the man page:

> The GNU version never modifies its argument, and returns the empty
> string when path has a trailing slash, and in particular also when it
> is "/".

So I think it might be best to just define an semanage_basename based
off the GNU behaviour as it is fairly trivial (being 2 LOC).

I'll send a patch to do this shortly.

Thanks,
Rahul

  reply	other threads:[~2025-02-21  9:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-20 21:12 [PATCH] libsemanage: define basename macro for non-glibc systems Rahul Sandhu
2025-02-21  0:16 ` William Roberts
2025-02-21  0:50   ` William Roberts
2025-02-21  5:52     ` Rahul Sandhu
2025-02-21  9:03       ` Rahul Sandhu [this message]
2025-02-21  9:39         ` [PATCH v2] libsemanage: create semanage_basename to ensure posix compliance Rahul Sandhu
2025-03-08 23:24           ` Rahul Sandhu
2025-03-19 19:29           ` James Carter
2025-04-07 18:06             ` James Carter

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=D7Y03RIRQTEH.1SUBF6LGYYEM6@gmail.com \
    --to=nvraxn@gmail.com \
    --cc=bill.c.roberts@gmail.com \
    --cc=selinux@vger.kernel.org \
    /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.