logind-acl.c revision 6b78df0a6ec75f25705a0f78ef895b95ab75a7ea
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2011 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <assert.h>
#include <errno.h>
#include <string.h>
#include "logind-acl.h"
#include "util.h"
#include "acl-util.h"
#include "set.h"
acl_entry_t i;
int found;
bool changed = false;
found > 0;
if (acl_get_tag_type(i, &tag) < 0)
return -errno;
continue;
if (acl_delete_entry(acl, i) < 0)
return -errno;
changed = true;
}
if (found < 0)
return -errno;
return changed;
}
int devnode_acl(const char *path,
bool flush,
int r = 0;
bool changed = false;
if (!acl)
return -errno;
if (flush) {
if (r < 0)
goto finish;
if (r > 0)
changed = true;
if (r < 0)
goto finish;
if (r > 0) {
r = -errno;
goto finish;
}
changed = true;
}
}
if (r < 0)
goto finish;
if (r == 0) {
r = -errno;
goto finish;
}
r = -errno;
goto finish;
}
}
r = -errno;
goto finish;
}
if (rd < 0) {
r = -errno;
goto finish;
}
if (wt < 0) {
r = -errno;
goto finish;
}
r = -errno;
goto finish;
}
changed = true;
}
}
if (!changed)
goto finish;
if (acl_calc_mask(&acl) < 0) {
r = -errno;
goto finish;
}
r = -errno;
goto finish;
}
r = 0;
return r;
}
const char *seat,
bool flush,
struct udev_enumerate *e;
Iterator i;
char *n;
int r;
if (!nodes) {
return -ENOMEM;
}
e = udev_enumerate_new(udev);
if (!e) {
r = -ENOMEM;
goto finish;
}
seat = "seat0";
/* We can only match by one tag in libudev. We choose
* "uaccess" for that. If we could match for two tags here we
* could add the seat name as second match tag, but this would
* be hardly optimizable in libudev, and hence checking the
* second tag manually in our loop is a good solution. */
r = udev_enumerate_add_match_tag(e, "uaccess");
if (r < 0)
goto finish;
r = udev_enumerate_scan_devices(e);
if (r < 0)
goto finish;
struct udev_device *d;
if (!d) {
r = -ENOMEM;
goto finish;
}
sn = "seat0";
continue;
}
node = udev_device_get_devnode(d);
if (!node) {
/* In case people mistag devices with nodes, we need to ignore this */
continue;
}
if (!n)
goto finish;
if (r < 0)
goto finish;
}
/* udev exports "dead" device nodes to allow module on-demand loading,
* these devices are not known to the kernel at this moment */
if (dir) {
continue;
if (unescaped_devname == NULL) {
r = -ENOMEM;
goto finish;
}
if (!n) {
r = -ENOMEM;
goto finish;
}
if (0 && r < 0 && r != -EEXIST) {
goto finish;
} else
r = 0;
}
}
SET_FOREACH(n, nodes, i) {
}
return r;
}