aboutsummaryrefslogtreecommitdiffstats
path: root/pseudo_util.c
diff options
context:
space:
mode:
authorPeter Seebach <seebs@eee12.(none)>2010-04-05 18:25:30 -0500
committerPeter Seebach <peter.seebach@windriver.com>2010-04-26 17:13:12 -0700
commitd686759bcfe87a08336470666283c4b2ab6ad510 (patch)
tree2b3361e223e8c7dffbde7a7ed6dbed0fc777da0a /pseudo_util.c
parent9517843c85e733df325aabe24b0fb16cc1beaf94 (diff)
downloadpseudo-d686759bcfe87a08336470666283c4b2ab6ad510.tar.gz
pseudo-d686759bcfe87a08336470666283c4b2ab6ad510.tar.bz2
pseudo-d686759bcfe87a08336470666283c4b2ab6ad510.zip
Add lckpwdf()/ulckpwdf().
It's not enough to rely on the usual chroot() stuff affecting the file open, not least because these use the glibc-internal __open which is not currently intercepted, but also because we want to use the PSEUDO_PASSWD path when that's set but there's no chroot(). There's some extra magic in pseudo_etc_file to support these operations, since they can legitimately create a file rather than opening an existing one.
Diffstat (limited to 'pseudo_util.c')
-rw-r--r--pseudo_util.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/pseudo_util.c b/pseudo_util.c
index 8b579f9..bef86ad 100644
--- a/pseudo_util.c
+++ b/pseudo_util.c
@@ -629,7 +629,7 @@ pseudo_access_fopen(const char *mode) {
*/
int
-pseudo_etc_file(char *file, char **search_dirs, int dircount) {
+pseudo_etc_file(const char *file, char *realname, int flags, char **search_dirs, int dircount) {
char filename[pseudo_path_max()];
int rc;
@@ -646,8 +646,10 @@ pseudo_etc_file(char *file, char **search_dirs, int dircount) {
continue;
snprintf(filename, pseudo_path_max(), "%s/etc/%s",
s, file);
- rc = open(filename, O_RDONLY);
+ rc = open(filename, flags);
if (rc >= 0) {
+ if (realname)
+ strcpy(realname, filename);
pseudo_debug(2, "using <%s> for <%s>\n",
filename, file);
return rc;
@@ -662,6 +664,9 @@ pseudo_etc_file(char *file, char **search_dirs, int dircount) {
snprintf(filename, pseudo_path_max(), "/etc/%s", file);
pseudo_debug(2, "falling back on <%s> for <%s>\n",
filename, file);
- return open(filename, O_RDONLY);
+ rc = open(filename, flags);
+ if (rc >= 0 && realname)
+ strcpy(realname, filename);
+ return rc;
}