All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Antill <jantill@redhat.com>
To: Eric Paris <eparis@parisplace.org>
Cc: selinux@tycho.nsa.gov
Subject: Re: [PATCH] libselinux: 1/2 Introduce {get,set}procattrcon
Date: Fri, 23 Jun 2006 21:00:22 -0400	[thread overview]
Message-ID: <1151110822.21635.125.camel@code.and.org> (raw)
In-Reply-To: <1151094766.21012.93.camel@localhost.localdomain>

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

On Fri, 2006-06-23 at 16:32 -0400, Eric Paris wrote:
> The below attached patch implements two new function, get and set
> procattrcon.  These are generic functions that take a context and a path
> and attempt to write that context to that path.  These are used by of
> exported libselinux interfaces, like getfscreatecon, as a generic
> backend to reduce duplication of code.

> --- libselinux-1.30.15/src/setprocattrcon.c.p1	2006-06-23 15:05:25.000000000 -0400
> +++ libselinux-1.30.15/src/setprocattrcon.c	2006-06-23 15:10:05.000000000 -0400
> @@ -0,0 +1,40 @@
> +#include <unistd.h>
> +#include <string.h>
> +#include <fcntl.h>
> +#include "selinux_internal.h"
> +
> +int setprocattrcon_raw(char *context, char *proc_entry)
> +{
> +	int fd;
> +	ssize_t ret;
> +
> +	fd = open(proc_entry, O_RDWR);
> +	if (fd < 0)
> +		return -1;
> +	if (context) 
> +		ret = write(fd, context, strlen(context)+1);
> +	else
> +		ret = write(fd, NULL, 0); /* clear */
> +	close(fd);

 Could you save and restore errno around the close? I know it didn't do
that before, but still...

> +	if (ret < 0)
> +		return -1;
> +	else
> +		return 0;
> +}
> +hidden_def(setprocattrcon_raw)
[...]
> +hidden_def(setprocattrcon)

 These make it impossible to call those functions from outside the
shared library, but you've declared them in the external header.

> --- libselinux-1.30.15/include/selinux/selinux.h.p1	2006-06-23 15:05:25.000000000 -0400
> +++ libselinux-1.30.15/include/selinux/selinux.h	2006-06-23 15:20:06.000000000 -0400
> @@ -24,6 +24,14 @@ extern void freeconary(security_context_
>  
>  /* Wrappers for the /proc/pid/attr API. */
>  
> +/* Generic /proc pid attr handlers.  These will either get or set the context
> +   from or into the proc location passed to them.  Should only be called from 
> +   inside libselinux */
> +extern int getprocattrcon(security_context_t *con, char *path);
> +extern int getprocattrcon_raw(security_context_t *con, char *path);
> +extern int setprocattrcon(security_context_t con, char *path);
> +extern int setprocattrcon_raw(security_context_t con, char *path);
> +
>  /* Get current context, and set *con to refer to it.
>     Caller must free via freecon. */
>  extern int getcon(security_context_t *con);

-- 
James Antill <jantill@redhat.com>

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2006-06-24  1:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-23 20:32 [PATCH] libselinux: 1/2 Introduce {get,set}procattrcon Eric Paris
2006-06-24  1:00 ` James Antill [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-06-26 16:48 Eric Paris
2006-06-26 18:31 ` Stephen Smalley
2006-06-26 19:38   ` Eric Paris
2006-06-26 20:15     ` Stephen Smalley
2006-06-27 20:30       ` 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=1151110822.21635.125.camel@code.and.org \
    --to=jantill@redhat.com \
    --cc=eparis@parisplace.org \
    --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.