Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
aports
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maxim Karasev
aports
Commits
26558bd1
Commit
26558bd1
authored
11 years ago
by
Timo Teräs
Browse files
Options
Downloads
Patches
Plain Diff
io: use fget{pw,gr}ent_r only on uclibc and glibc
musl does not have those.
parent
4fad6d9c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/io.c
+23
-4
23 additions, 4 deletions
src/io.c
with
23 additions
and
4 deletions
src/io.c
+
23
−
4
View file @
26558bd1
...
@@ -25,6 +25,11 @@
...
@@ -25,6 +25,11 @@
#include
"apk_io.h"
#include
"apk_io.h"
#include
"apk_hash.h"
#include
"apk_hash.h"
#if defined(__GLIBC__) || defined(__UCLIBC__)
#define HAVE_FGETPWENT_R
#define HAVE_FGETGRENT_R
#endif
struct
apk_fd_istream
{
struct
apk_fd_istream
{
struct
apk_istream
is
;
struct
apk_istream
is
;
int
fd
;
int
fd
;
...
@@ -908,9 +913,12 @@ void apk_id_cache_reset(struct apk_id_cache *idc)
...
@@ -908,9 +913,12 @@ void apk_id_cache_reset(struct apk_id_cache *idc)
uid_t
apk_resolve_uid
(
struct
apk_id_cache
*
idc
,
const
char
*
username
,
uid_t
default_uid
)
uid_t
apk_resolve_uid
(
struct
apk_id_cache
*
idc
,
const
char
*
username
,
uid_t
default_uid
)
{
{
struct
cache_item
*
ci
;
#ifdef HAVE_FGETPWENT_R
struct
passwd
pwent
,
*
pwd
;
char
buf
[
1024
];
char
buf
[
1024
];
struct
passwd
pwent
;
#endif
struct
cache_item
*
ci
;
struct
passwd
*
pwd
;
FILE
*
in
;
FILE
*
in
;
ci
=
resolve_cache_item
(
&
idc
->
uid_cache
,
APK_BLOB_STR
(
username
));
ci
=
resolve_cache_item
(
&
idc
->
uid_cache
,
APK_BLOB_STR
(
username
));
...
@@ -924,7 +932,11 @@ uid_t apk_resolve_uid(struct apk_id_cache *idc, const char *username, uid_t defa
...
@@ -924,7 +932,11 @@ uid_t apk_resolve_uid(struct apk_id_cache *idc, const char *username, uid_t defa
in
=
fdopen
(
openat
(
idc
->
root_fd
,
"etc/passwd"
,
O_RDONLY
|
O_CLOEXEC
),
"r"
);
in
=
fdopen
(
openat
(
idc
->
root_fd
,
"etc/passwd"
,
O_RDONLY
|
O_CLOEXEC
),
"r"
);
if
(
in
!=
NULL
)
{
if
(
in
!=
NULL
)
{
do
{
do
{
#ifdef HAVE_FGETPWENT_R
fgetpwent_r
(
in
,
&
pwent
,
buf
,
sizeof
(
buf
),
&
pwd
);
fgetpwent_r
(
in
,
&
pwent
,
buf
,
sizeof
(
buf
),
&
pwd
);
#else
pwd
=
fgetpwent
(
in
);
#endif
if
(
pwd
==
NULL
)
if
(
pwd
==
NULL
)
break
;
break
;
if
(
strcmp
(
pwd
->
pw_name
,
username
)
==
0
)
{
if
(
strcmp
(
pwd
->
pw_name
,
username
)
==
0
)
{
...
@@ -944,9 +956,12 @@ uid_t apk_resolve_uid(struct apk_id_cache *idc, const char *username, uid_t defa
...
@@ -944,9 +956,12 @@ uid_t apk_resolve_uid(struct apk_id_cache *idc, const char *username, uid_t defa
uid_t
apk_resolve_gid
(
struct
apk_id_cache
*
idc
,
const
char
*
groupname
,
uid_t
default_gid
)
uid_t
apk_resolve_gid
(
struct
apk_id_cache
*
idc
,
const
char
*
groupname
,
uid_t
default_gid
)
{
{
struct
cache_item
*
ci
;
#ifdef HAVE_FGETGRENT_R
struct
group
grent
,
*
grp
;
char
buf
[
1024
];
char
buf
[
1024
];
struct
group
grent
;
#endif
struct
cache_item
*
ci
;
struct
group
*
grp
;
FILE
*
in
;
FILE
*
in
;
ci
=
resolve_cache_item
(
&
idc
->
gid_cache
,
APK_BLOB_STR
(
groupname
));
ci
=
resolve_cache_item
(
&
idc
->
gid_cache
,
APK_BLOB_STR
(
groupname
));
...
@@ -960,7 +975,11 @@ uid_t apk_resolve_gid(struct apk_id_cache *idc, const char *groupname, uid_t def
...
@@ -960,7 +975,11 @@ uid_t apk_resolve_gid(struct apk_id_cache *idc, const char *groupname, uid_t def
in
=
fdopen
(
openat
(
idc
->
root_fd
,
"etc/group"
,
O_RDONLY
|
O_CLOEXEC
),
"r"
);
in
=
fdopen
(
openat
(
idc
->
root_fd
,
"etc/group"
,
O_RDONLY
|
O_CLOEXEC
),
"r"
);
if
(
in
!=
NULL
)
{
if
(
in
!=
NULL
)
{
do
{
do
{
#ifdef HAVE_FGETGRENT_R
fgetgrent_r
(
in
,
&
grent
,
buf
,
sizeof
(
buf
),
&
grp
);
fgetgrent_r
(
in
,
&
grent
,
buf
,
sizeof
(
buf
),
&
grp
);
#else
grp
=
fgetgrent
(
in
);
#endif
if
(
grp
==
NULL
)
if
(
grp
==
NULL
)
break
;
break
;
if
(
strcmp
(
grp
->
gr_name
,
groupname
)
==
0
)
{
if
(
strcmp
(
grp
->
gr_name
,
groupname
)
==
0
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment