Skip to content

Commit 32f641b

Browse files
committed
Change the subid export symbols
Rename libsubid symbols to all be prefixed with subid_. Don't export anything but the subid_*. Closes #443 Signed-off-by: Serge Hallyn <[email protected]>
1 parent 9724147 commit 32f641b

8 files changed

Lines changed: 37 additions & 36 deletions

File tree

‎configure.ac‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dnl Process this file with autoconf to produce a configure script.
22
AC_PREREQ([2.69])
3-
m4_define([libsubid_abi_major], 3)
3+
m4_define([libsubid_abi_major], 4)
44
m4_define([libsubid_abi_minor], 0)
55
m4_define([libsubid_abi_micro], 0)
66
m4_define([libsubid_abi], [libsubid_abi_major.libsubid_abi_minor.libsubid_abi_micro])

‎libsubid/Makefile.am‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ libsubid_la_LDFLAGS = -Wl,-soname,libsubid.so.@LIBSUBID_ABI@ \
44
-shared -version-info @LIBSUBID_ABI_MAJOR@
55
endif
66
libsubid_la_SOURCES = api.c
7+
libsubid_la_LDFLAGS = -export-symbols-regex '^subid_'
78

89
pkginclude_HEADERS = subid.h
910

‎libsubid/api.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
static const char *Prog = "(libsubid)";
4343
static FILE *shadow_logfd;
4444

45-
bool libsubid_init(const char *progname, FILE * logfd)
45+
bool subid_init(const char *progname, FILE * logfd)
4646
{
4747
if (progname) {
4848
progname = strdup(progname);
@@ -70,12 +70,12 @@ int get_subid_ranges(const char *owner, enum subid_type id_type, struct subid_ra
7070
return list_owner_ranges(owner, id_type, ranges);
7171
}
7272

73-
int get_subuid_ranges(const char *owner, struct subid_range **ranges)
73+
int subid_get_uid_ranges(const char *owner, struct subid_range **ranges)
7474
{
7575
return get_subid_ranges(owner, ID_TYPE_UID, ranges);
7676
}
7777

78-
int get_subgid_ranges(const char *owner, struct subid_range **ranges)
78+
int subid_get_gid_ranges(const char *owner, struct subid_range **ranges)
7979
{
8080
return get_subid_ranges(owner, ID_TYPE_GID, ranges);
8181
}
@@ -86,12 +86,12 @@ int get_subid_owner(unsigned long id, enum subid_type id_type, uid_t **owner)
8686
return find_subid_owners(id, id_type, owner);
8787
}
8888

89-
int get_subuid_owners(uid_t uid, uid_t **owner)
89+
int subid_get_uid_owners(uid_t uid, uid_t **owner)
9090
{
9191
return get_subid_owner((unsigned long)uid, ID_TYPE_UID, owner);
9292
}
9393

94-
int get_subgid_owners(gid_t gid, uid_t **owner)
94+
int subid_get_gid_owners(gid_t gid, uid_t **owner)
9595
{
9696
return get_subid_owner((unsigned long)gid, ID_TYPE_GID, owner);
9797
}
@@ -103,12 +103,12 @@ bool grant_subid_range(struct subordinate_range *range, bool reuse,
103103
return new_subid_range(range, id_type, reuse);
104104
}
105105

106-
bool grant_subuid_range(struct subordinate_range *range, bool reuse)
106+
bool subid_grant_uid_range(struct subordinate_range *range, bool reuse)
107107
{
108108
return grant_subid_range(range, reuse, ID_TYPE_UID);
109109
}
110110

111-
bool grant_subgid_range(struct subordinate_range *range, bool reuse)
111+
bool subid_grant_gid_range(struct subordinate_range *range, bool reuse)
112112
{
113113
return grant_subid_range(range, reuse, ID_TYPE_GID);
114114
}
@@ -119,12 +119,12 @@ bool ungrant_subid_range(struct subordinate_range *range, enum subid_type id_typ
119119
return release_subid_range(range, id_type);
120120
}
121121

122-
bool ungrant_subuid_range(struct subordinate_range *range)
122+
bool subid_ungrant_uid_range(struct subordinate_range *range)
123123
{
124124
return ungrant_subid_range(range, ID_TYPE_UID);
125125
}
126126

127-
bool ungrant_subgid_range(struct subordinate_range *range)
127+
bool subid_ungrant_gid_range(struct subordinate_range *range)
128128
{
129129
return ungrant_subid_range(range, ID_TYPE_GID);
130130
}

‎libsubid/subid.h‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ enum subid_status {
3232
};
3333

3434
/*
35-
* libsubid_init: initialize libsubid
35+
* subid_init: initialize libsubid
3636
*
3737
* @progname: Name to display as program. If NULL, then "(libsubid)" will be
3838
* shown in error messages.
@@ -45,10 +45,10 @@ enum subid_status {
4545
*
4646
* Returns false if an error occurred.
4747
*/
48-
bool libsubid_init(const char *progname, FILE *logfd);
48+
bool subid_init(const char *progname, FILE *logfd);
4949

5050
/*
51-
* get_subuid_ranges: return a list of UID ranges for a user
51+
* subid_get_uid_ranges: return a list of UID ranges for a user
5252
*
5353
* @owner: username being queried
5454
* @ranges: a pointer to an array of subid_range structs in which the result
@@ -58,10 +58,10 @@ bool libsubid_init(const char *progname, FILE *logfd);
5858
*
5959
* returns: number of ranges found, ir < 0 on error.
6060
*/
61-
int get_subuid_ranges(const char *owner, struct subid_range **ranges);
61+
int subid_get_uid_ranges(const char *owner, struct subid_range **ranges);
6262

6363
/*
64-
* get_subgid_ranges: return a list of GID ranges for a user
64+
* subid_get_gid_ranges: return a list of GID ranges for a user
6565
*
6666
* @owner: username being queried
6767
* @ranges: a pointer to an array of subid_range structs in which the result
@@ -71,10 +71,10 @@ int get_subuid_ranges(const char *owner, struct subid_range **ranges);
7171
*
7272
* returns: number of ranges found, ir < 0 on error.
7373
*/
74-
int get_subgid_ranges(const char *owner, struct subid_range **ranges);
74+
int subid_get_gid_ranges(const char *owner, struct subid_range **ranges);
7575

7676
/*
77-
* get_subuid_owners: return a list of uids to which the given uid has been
77+
* subid_get_uid_owners: return a list of uids to which the given uid has been
7878
* delegated.
7979
*
8080
* @uid: The subuid being queried
@@ -83,10 +83,10 @@ int get_subgid_ranges(const char *owner, struct subid_range **ranges);
8383
*
8484
* Returns the number of uids returned, or < 0 on error.
8585
*/
86-
int get_subuid_owners(uid_t uid, uid_t **owner);
86+
int subid_get_uid_owners(uid_t uid, uid_t **owner);
8787

8888
/*
89-
* get_subgid_owners: return a list of uids to which the given gid has been
89+
* subid_get_gid_owners: return a list of uids to which the given gid has been
9090
* delegated.
9191
*
9292
* @uid: The subgid being queried
@@ -95,10 +95,10 @@ int get_subuid_owners(uid_t uid, uid_t **owner);
9595
*
9696
* Returns the number of uids returned, or < 0 on error.
9797
*/
98-
int get_subgid_owners(gid_t gid, uid_t **owner);
98+
int subid_get_gid_owners(gid_t gid, uid_t **owner);
9999

100100
/*
101-
* grant_subuid_range: assign a subuid range to a user
101+
* subid_grant_uid_range: assign a subuid range to a user
102102
*
103103
* @range: pointer to a struct subordinate_range detailing the UID range
104104
* to allocate. ->owner must be the username, and ->count must be
@@ -109,10 +109,10 @@ int get_subgid_owners(gid_t gid, uid_t **owner);
109109
* then the range from (range->start, range->start + range->count) will
110110
* be delegated to range->owner.
111111
*/
112-
bool grant_subuid_range(struct subordinate_range *range, bool reuse);
112+
bool subid_grant_uid_range(struct subordinate_range *range, bool reuse);
113113

114114
/*
115-
* grant_subsid_range: assign a subgid range to a user
115+
* subid_grant_gid_range: assign a subgid range to a user
116116
*
117117
* @range: pointer to a struct subordinate_range detailing the GID range
118118
* to allocate. ->owner must be the username, and ->count must be
@@ -123,29 +123,29 @@ bool grant_subuid_range(struct subordinate_range *range, bool reuse);
123123
* then the range from (range->start, range->start + range->count) will
124124
* be delegated to range->owner.
125125
*/
126-
bool grant_subgid_range(struct subordinate_range *range, bool reuse);
126+
bool subid_grant_gid_range(struct subordinate_range *range, bool reuse);
127127

128128
/*
129-
* ungrant_subuid_range: remove a subuid allocation.
129+
* subid_ungrant_uid_range: remove a subuid allocation.
130130
*
131131
* @range: pointer to a struct subordinate_range detailing the UID allocation
132132
* to remove.
133133
*
134134
* Returns true if successful, false if it failed, for instance if the
135135
* delegation did not exist.
136136
*/
137-
bool ungrant_subuid_range(struct subordinate_range *range);
137+
bool subid_ungrant_uid_range(struct subordinate_range *range);
138138

139139
/*
140-
* ungrant_subuid_range: remove a subgid allocation.
140+
* subid_ungrant_gid_range: remove a subgid allocation.
141141
*
142142
* @range: pointer to a struct subordinate_range detailing the GID allocation
143143
* to remove.
144144
*
145145
* Returns true if successful, false if it failed, for instance if the
146146
* delegation did not exist.
147147
*/
148-
bool ungrant_subgid_range(struct subordinate_range *range);
148+
bool subid_ungrant_gid_range(struct subordinate_range *range);
149149

150150
#define SUBID_NFIELDS 3
151151
#endif

‎src/free_subid_range.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ int main(int argc, char *argv[])
3939
range.start = atoi(argv[1]);
4040
range.count = atoi(argv[2]);
4141
if (group)
42-
ok = ungrant_subgid_range(&range);
42+
ok = subid_ungrant_gid_range(&range);
4343
else
44-
ok = ungrant_subuid_range(&range);
44+
ok = subid_ungrant_uid_range(&range);
4545

4646
if (!ok) {
4747
fprintf(stderr, "Failed freeing id range\n");

‎src/get_subid_owners.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ int main(int argc, char *argv[])
2525
usage();
2626
}
2727
if (argc == 3 && strcmp(argv[1], "-g") == 0)
28-
n = get_subgid_owners(atoi(argv[2]), &uids);
28+
n = subid_get_gid_owners(atoi(argv[2]), &uids);
2929
else if (argc == 2 && strcmp(argv[1], "-h") == 0)
3030
usage();
3131
else
32-
n = get_subuid_owners(atoi(argv[1]), &uids);
32+
n = subid_get_uid_owners(atoi(argv[1]), &uids);
3333
if (n < 0) {
3434
fprintf(stderr, "No owners found\n");
3535
exit(1);

‎src/getsubids.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ int main(int argc, char *argv[])
2828
owner = argv[1];
2929
if (argc == 3 && strcmp(argv[1], "-g") == 0) {
3030
owner = argv[2];
31-
count = get_subgid_ranges(owner, &ranges);
31+
count = subid_get_gid_ranges(owner, &ranges);
3232
} else if (argc == 2 && strcmp(argv[1], "-h") == 0) {
3333
usage();
3434
} else {
35-
count = get_subuid_ranges(owner, &ranges);
35+
count = subid_get_uid_ranges(owner, &ranges);
3636
}
3737
if (!ranges) {
3838
fprintf(stderr, "Error fetching ranges\n");

‎src/new_subid_range.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ int main(int argc, char *argv[])
4545
if (argc > 1)
4646
range.count = atoi(argv[1]);
4747
if (group)
48-
ok = grant_subgid_range(&range, !makenew);
48+
ok = subid_grant_gid_range(&range, !makenew);
4949
else
50-
ok = grant_subuid_range(&range, !makenew);
50+
ok = subid_grant_uid_range(&range, !makenew);
5151

5252
if (!ok) {
5353
fprintf(stderr, "Failed creating new id range\n");

0 commit comments

Comments
 (0)