summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBalint Reczey <balint.reczey@canonical.com>2019-03-03 23:31:24 +0100
committerBalint Reczey <balint.reczey@canonical.com>2019-03-03 23:31:24 +0100
commitb0729855e8fb744192a0395ea24673557818172c (patch)
treef2c3f13b5ba33b0b1f3627c24cd4005e0972ff86 /lib
parent589f97ade4610b98cc532c8142343d4c33694e72 (diff)
downloadshadow-b0729855e8fb744192a0395ea24673557818172c.tar.gz
New upstream version 4.6upstream/4.6
Diffstat (limited to 'lib')
-rw-r--r--lib/commonio.c38
-rw-r--r--lib/defines.h2
-rw-r--r--lib/getdef.c13
-rw-r--r--lib/getdef.h1
-rw-r--r--lib/prototypes.h19
-rw-r--r--lib/subordinateio.c6
6 files changed, 63 insertions, 16 deletions
diff --git a/lib/commonio.c b/lib/commonio.c
index 31edbaaf..d06b8e7d 100644
--- a/lib/commonio.c
+++ b/lib/commonio.c
@@ -375,28 +375,48 @@ bool commonio_present (const struct commonio_db *db)
int commonio_lock_nowait (struct commonio_db *db, bool log)
{
- char file[1024];
- char lock[1024];
+ char* file = NULL;
+ char* lock = NULL;
+ size_t lock_file_len;
+ size_t file_len;
+ int err;
if (db->locked) {
return 1;
}
-
- snprintf (file, sizeof file, "%s.%lu",
+ file_len = strlen(db->filename) + 11;/* %lu max size */
+ lock_file_len = strlen(db->filename) + 6; /* sizeof ".lock" */
+ file = (char*)malloc(file_len);
+ if(file == NULL) {
+ err = ENOMEM;
+ goto cleanup_ENOMEM;
+ }
+ lock = (char*)malloc(lock_file_len);
+ if(lock == NULL) {
+ err = ENOMEM;
+ goto cleanup_ENOMEM;
+ }
+ snprintf (file, file_len, "%s.%lu",
db->filename, (unsigned long) getpid ());
- snprintf (lock, sizeof lock, "%s.lock", db->filename);
+ snprintf (lock, lock_file_len, "%s.lock", db->filename);
if (do_lock_file (file, lock, log) != 0) {
db->locked = true;
lock_count++;
- return 1;
- }
- return 0;
+ err = 1;
+ }
+cleanup_ENOMEM:
+ if(file)
+ free(file);
+ if(lock)
+ free(lock);
+ return err;
}
int commonio_lock (struct commonio_db *db)
{
-#ifdef HAVE_LCKPWDF
+/*#ifdef HAVE_LCKPWDF*/ /* not compatible with prefix option*/
+#if 0
/*
* only if the system libc has a real lckpwdf() - the one from
* lockpw.c calls us and would cause infinite recursion!
diff --git a/lib/defines.h b/lib/defines.h
index 62bd73e5..cded1417 100644
--- a/lib/defines.h
+++ b/lib/defines.h
@@ -24,7 +24,7 @@ typedef unsigned char _Bool;
/* Take care of NLS matters. */
#ifdef S_SPLINT_S
-extern char *setlocale(int categorie, const char *locale);
+extern char *setlocale(int categories, const char *locale);
# define LC_ALL (6)
extern char * bindtextdomain (const char * domainname, const char * dirname);
extern char * textdomain (const char * domainname);
diff --git a/lib/getdef.c b/lib/getdef.c
index a181cc2b..d57b12de 100644
--- a/lib/getdef.c
+++ b/lib/getdef.c
@@ -155,7 +155,7 @@ static struct itemdef knowndef_table[] = {
#define LOGINDEFS "/etc/login.defs"
#endif
-static char def_fname[] = LOGINDEFS; /* login config defs file */
+static const char* def_fname = LOGINDEFS; /* login config defs file */
static bool def_loaded = false; /* are defs already loaded? */
/* local function prototypes */
@@ -425,6 +425,17 @@ out:
}
/*
+ * setdef_config_file - set the default configuration file path
+ *
+ * must be called prior to any def* calls.
+ */
+
+void setdef_config_file (const char* file)
+{
+ def_fname = file;
+}
+
+/*
* def_load - load configuration table
*
* Loads the user-configured options from the default configuration file
diff --git a/lib/getdef.h b/lib/getdef.h
index 15e35ff7..46346d8e 100644
--- a/lib/getdef.h
+++ b/lib/getdef.h
@@ -40,6 +40,7 @@ extern unsigned long getdef_ulong (const char *, unsigned long);
extern unsigned int getdef_unum (const char *, unsigned int);
extern /*@observer@*/ /*@null@*/const char *getdef_str (const char *);
extern int putdef_str (const char *, const char *);
+extern void setdef_config_file (const char* file);
/* default UMASK value if not specified in /etc/login.defs */
#define GETDEF_DEFAULT_UMASK 022
diff --git a/lib/prototypes.h b/lib/prototypes.h
index 4808d5d9..b7d48881 100644
--- a/lib/prototypes.h
+++ b/lib/prototypes.h
@@ -254,9 +254,9 @@ extern void motd (void);
/* myname.c */
extern /*@null@*//*@only@*/struct passwd *get_my_pwent (void);
-/* pam_pass_non_interractive.c */
+/* pam_pass_non_interactive.c */
#ifdef USE_PAM
-extern int do_pam_passwd_non_interractive (const char *pam_service,
+extern int do_pam_passwd_non_interactive (const char *pam_service,
const char *username,
const char* password);
#endif /* USE_PAM */
@@ -274,6 +274,21 @@ extern void do_pam_passwd (const char *user, bool silent, bool change_expired);
/* port.c */
extern bool isttytime (const char *, const char *, time_t);
+/* prefix_flag.c */
+extern const char* process_prefix_flag (const char* short_opt, int argc, char **argv);
+extern struct group *prefix_getgrnam(const char *name);
+extern struct group *prefix_getgrgid(gid_t gid);
+extern struct passwd *prefix_getpwuid(uid_t uid);
+extern struct passwd *prefix_getpwnam(const char* name);
+extern struct spwd *prefix_getspnam(const char* name);
+extern struct group *prefix_getgr_nam_gid(const char *grname);
+extern void prefix_setpwent();
+extern struct passwd* prefix_getpwent();
+extern void prefix_endpwent();
+extern void prefix_setgrent();
+extern struct group* prefix_getgrent();
+extern void prefix_endgrent();
+
/* pwd2spwd.c */
#ifndef USE_PAM
extern struct spwd *pwd_to_spwd (const struct passwd *);
diff --git a/lib/subordinateio.c b/lib/subordinateio.c
index 0d64a914..a662e67e 100644
--- a/lib/subordinateio.c
+++ b/lib/subordinateio.c
@@ -181,7 +181,7 @@ static const bool range_exists(struct commonio_db *db, const char *owner)
* subuid @val.
*
* @db: database to query
- * @owner: owning uid being queuried
+ * @owner: owning uid being queried
* @val: subuid being searched for.
*
* Returns a range of subuids belonging to @owner and including the subuid
@@ -221,7 +221,7 @@ static const struct subordinate_range *find_range(struct commonio_db *db,
/*
* Search loop above did not produce any result. Let's rerun it,
- * but this time try to matcha actual UIDs. The first entry that
+ * but this time try to match actual UIDs. The first entry that
* matches is considered a success.
* (It may be specified as literal UID or as another username which
* has the same UID as the username we are looking for.)
@@ -418,7 +418,7 @@ fail:
* @start: the first uid in the owned range
* @count: the number of uids in the range
*
- * Return 1 if the range is already present or on succcess. On error
+ * Return 1 if the range is already present or on success. On error
* return 0 and set errno appropriately.
*/
static int add_range(struct commonio_db *db,