diff options
author | Balint Reczey <balint@balintreczey.hu> | 2022-01-21 23:41:15 +0100 |
---|---|---|
committer | Balint Reczey <balint@balintreczey.hu> | 2022-01-21 23:41:15 +0100 |
commit | 0c04b92a9afe5e09a20307d8a5ec98d97ed00f47 (patch) | |
tree | 27f51b8f32e23b65d2ef2bbbae00c19fd036e81d /libsubid/api.c | |
parent | 749c1780621163ca5108f164861324bafa9e0ae8 (diff) | |
download | shadow-0c04b92a9afe5e09a20307d8a5ec98d97ed00f47.tar.gz |
New upstream version 4.11.1+dfsg1upstream/4.11.1+dfsg1
Diffstat (limited to 'libsubid/api.c')
-rw-r--r-- | libsubid/api.c | 62 |
1 files changed, 20 insertions, 42 deletions
diff --git a/libsubid/api.c b/libsubid/api.c index a7b904d0..00da74f6 100644 --- a/libsubid/api.c +++ b/libsubid/api.c @@ -1,30 +1,7 @@ /* - * Copyright (c) 2020 Serge Hallyn - * All rights reserved. + * SPDX-FileCopyrightText: 2020 Serge Hallyn * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the copyright holders or contributors may not be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include <config.h> @@ -38,29 +15,30 @@ #include "subordinateio.h" #include "idmapping.h" #include "subid.h" +#include "shadowlog.h" -const char *Prog = "(libsubid)"; -FILE *shadow_logfd; - -bool libsubid_init(const char *progname, FILE * logfd) +bool subid_init(const char *progname, FILE * logfd) { + FILE *shadow_logfd; if (progname) { progname = strdup(progname); - if (progname) - Prog = progname; - else + if (!progname) return false; + log_set_progname(progname); + } else { + log_set_progname("(libsubid)"); } if (logfd) { - shadow_logfd = logfd; + log_set_logfd(logfd); return true; } shadow_logfd = fopen("/dev/null", "w"); if (!shadow_logfd) { - shadow_logfd = stderr; + log_set_logfd(stderr); return false; } + log_set_logfd(shadow_logfd); return true; } @@ -70,12 +48,12 @@ int get_subid_ranges(const char *owner, enum subid_type id_type, struct subid_ra return list_owner_ranges(owner, id_type, ranges); } -int get_subuid_ranges(const char *owner, struct subid_range **ranges) +int subid_get_uid_ranges(const char *owner, struct subid_range **ranges) { return get_subid_ranges(owner, ID_TYPE_UID, ranges); } -int get_subgid_ranges(const char *owner, struct subid_range **ranges) +int subid_get_gid_ranges(const char *owner, struct subid_range **ranges) { return get_subid_ranges(owner, ID_TYPE_GID, ranges); } @@ -86,12 +64,12 @@ int get_subid_owner(unsigned long id, enum subid_type id_type, uid_t **owner) return find_subid_owners(id, id_type, owner); } -int get_subuid_owners(uid_t uid, uid_t **owner) +int subid_get_uid_owners(uid_t uid, uid_t **owner) { return get_subid_owner((unsigned long)uid, ID_TYPE_UID, owner); } -int get_subgid_owners(gid_t gid, uid_t **owner) +int subid_get_gid_owners(gid_t gid, uid_t **owner) { return get_subid_owner((unsigned long)gid, ID_TYPE_GID, owner); } @@ -103,12 +81,12 @@ bool grant_subid_range(struct subordinate_range *range, bool reuse, return new_subid_range(range, id_type, reuse); } -bool grant_subuid_range(struct subordinate_range *range, bool reuse) +bool subid_grant_uid_range(struct subordinate_range *range, bool reuse) { return grant_subid_range(range, reuse, ID_TYPE_UID); } -bool grant_subgid_range(struct subordinate_range *range, bool reuse) +bool subid_grant_gid_range(struct subordinate_range *range, bool reuse) { return grant_subid_range(range, reuse, ID_TYPE_GID); } @@ -119,12 +97,12 @@ bool ungrant_subid_range(struct subordinate_range *range, enum subid_type id_typ return release_subid_range(range, id_type); } -bool ungrant_subuid_range(struct subordinate_range *range) +bool subid_ungrant_uid_range(struct subordinate_range *range) { return ungrant_subid_range(range, ID_TYPE_UID); } -bool ungrant_subgid_range(struct subordinate_range *range) +bool subid_ungrant_gid_range(struct subordinate_range *range) { return ungrant_subid_range(range, ID_TYPE_GID); } |