clean-ipc.c revision f7dc3ab9f43b67abcbd34062b9352ab42debec49
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright 2014 Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Lesser General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering You should have received a copy of the GNU Lesser General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersenstatic int clean_sysvipc_shm(uid_t delete_uid) {
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen log_warning("Failed to open /proc/sysvipc/shm: %m");
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen if (sscanf(line, "%*i %i %*o %*u " PID_FMT " " PID_FMT " %u " UID_FMT " " GID_FMT " " UID_FMT " " GID_FMT,
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen &shmid, &cpid, &lpid, &n_attached, &uid, &gid, &cuid, &cgid) != 8)
b652d4a2099d1c167584dcc1d179d47c58dc38a2Lennart Poettering /* Ignore entries that are already deleted */
b652d4a2099d1c167584dcc1d179d47c58dc38a2Lennart Poettering log_warning("Failed to remove SysV shared memory segment %i: %m", shmid);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_warning("Failed to read /proc/sysvipc/shm: %m");
0dd25fb9f005d8ab7ac4bc10a609d00569f8c56aLennart Poetteringstatic int clean_sysvipc_sem(uid_t delete_uid) {
f4461e5641d53f27d6e76e0607bdaa9c0c58c1f6Lennart Poettering log_warning("Failed to open /proc/sysvipc/sem: %m");
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering if (sscanf(line, "%*i %i %*o %*u " UID_FMT " " GID_FMT " " UID_FMT " " GID_FMT,
return ret;
fail:
return -errno;
bool first = true;
int ret = 0;
return -errno;
int msgid;
if (first) {
first = false;
if (sscanf(line, "%*i %i %*o %*u %*u " PID_FMT " " PID_FMT " " UID_FMT " " GID_FMT " " UID_FMT " " GID_FMT,
return ret;
fail:
return -errno;
int ret = 0, r;
if (!kid) {
ret = r;
return ret;
fail:
return -errno;
if (!dir) {
return -errno;
int ret = 0;
if (!dir) {
return -errno;
return ret;
fail:
return -errno;
int ret = 0, r;
ret = r;
ret = r;
ret = r;
ret = r;
ret = r;
return ret;