aboutsummaryrefslogtreecommitdiff
path: root/login/programs
diff options
context:
space:
mode:
Diffstat (limited to 'login/programs')
-rw-r--r--login/programs/database.c5
-rw-r--r--login/programs/utmpd.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/login/programs/database.c b/login/programs/database.c
index 087ec54d26..00d573f336 100644
--- a/login/programs/database.c
+++ b/login/programs/database.c
@@ -52,6 +52,7 @@ static int get_mtime (int filedes, time_t *timer);
utmp_database *
open_database (const char *file, const char *old_file)
{
+ mode_t mode = S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH;
utmp_database *database;
/* Allocate memory. */
@@ -65,7 +66,7 @@ open_database (const char *file, const char *old_file)
memset (database, 0, sizeof (utmp_database));
/* Open database, create it if it doesn't exist already. */
- database->fd = open (file, O_RDWR | O_CREAT);
+ database->fd = open (file, O_RDWR | O_CREAT, mode);
if (database->fd < 0)
{
error (0, errno, "%s", file);
@@ -81,7 +82,7 @@ open_database (const char *file, const char *old_file)
if (old_file)
{
- database->old_fd = open (old_file, O_RDWR);
+ database->old_fd = open (old_file, O_RDWR|O_CREAT, mode);
if (database->old_fd < 0)
{
error (0, errno, "%s", old_file);
diff --git a/login/programs/utmpd.c b/login/programs/utmpd.c
index 1469d94ca7..e0648ebb42 100644
--- a/login/programs/utmpd.c
+++ b/login/programs/utmpd.c
@@ -141,6 +141,10 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
if (check_pid (_PATH_UTMPDPID))
error (EXIT_FAILURE, 0, _("already running"));
+ /* Cleanup files created by a previous `bind'. */
+ unlink (_PATH_UTMPD_RO);
+ unlink (_PATH_UTMPD_RW);
+
/* Open UTMP database. */
utmp_db = open_database (_PATH_UTMP "x", _PATH_UTMP);
if (utmp_db == NULL)
@@ -248,6 +252,7 @@ make_socket (const char *name)
size = (offsetof (struct sockaddr_un, sun_path)
+ strlen (addr.sun_path));
+
if (bind (sock, (struct sockaddr *) &addr, size) < 0)
error (EXIT_FAILURE, errno, "%s", name);