udev-builtin-uaccess.c revision 79d860fe78ff9e53fe3150fb55a8a8b03c4f6470
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers * manage device node user ACL
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers * Copyright 2010-2012 Kay Sievers <kay@vrfy.org>
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers * Copyright 2010 Lennart Poettering
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers * This program is free software: you can redistribute it and/or modify
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers * it under the terms of the GNU General Public License as published by
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers * the Free Software Foundation, either version 2 of the License, or
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers * (at your option) any later version.
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers * This program is distributed in the hope that it will be useful,
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers * but WITHOUT ANY WARRANTY; without even the implied warranty of
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers * GNU General Public License for more details.
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers * You should have received a copy of the GNU General Public License
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers * along with this program. If not, see <http://www.gnu.org/licenses/>.
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sieversstatic int builtin_uaccess(struct udev_device *dev, int argc, char *argv[], bool test)
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers /* don't muck around with ACLs when the system is not running systemd */
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers seat = udev_device_get_property_value(dev, "ID_SEAT");
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers /* No active session on this seat */
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers } else if (r < 0) {
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers log_error("Failed to determine active user on seat %s.", seat);
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers r = devnode_acl(path, true, false, 0, true, uid);
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers if (r < 0) {
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers log_error("Failed to apply ACL on %s: %s", path, strerror(-r));
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers /* Better be safe than sorry and reset ACL */
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers k = devnode_acl(path, true, false, 0, false, 0);
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers if (k < 0) {
83cd6b754b270091840456a2c8a66dae19f5a7dcKay Sievers log_error("Failed to apply ACL on %s: %s", path, strerror(-k));