mirror of
https://github.com/troglobit/finit.git
synced 2026-11-01 13:10:32 +00:00
bootmisc: Check return value from chmod() API
Found by Coverity Scan. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
bb0505f57c
commit
bb7208c591
1 file changed
+13
-12
+13
-12
@@ -30,6 +30,12 @@
|
|||||||
#include "../plugin.h"
|
#include "../plugin.h"
|
||||||
#include "../utmp-api.h"
|
#include "../utmp-api.h"
|
||||||
|
|
||||||
|
static void create(char *path, mode_t mode, uid_t uid, gid_t gid)
|
||||||
|
{
|
||||||
|
if (touch(path) || chmod(path, mode) || chown(path, uid, gid))
|
||||||
|
_w("Failed creating %s properl.", path);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup standard FHS 2.3 structure in /var, and write runlevel to UTMP
|
* Setup standard FHS 2.3 structure in /var, and write runlevel to UTMP
|
||||||
*/
|
*/
|
||||||
@@ -72,18 +78,13 @@ static void setup(void *UNUSED(arg))
|
|||||||
if (gid < 0)
|
if (gid < 0)
|
||||||
gid = 0;
|
gid = 0;
|
||||||
|
|
||||||
touch("/var/run/utmp");
|
/*
|
||||||
chmod("/var/run/utmp", 0664);
|
* UTMP actually needs multiple db files
|
||||||
chown("/var/run/utmp", 0, gid);
|
*/
|
||||||
touch("/var/log/wtmp");
|
create("/var/run/utmp", 0644, 0, gid); /* Currently logged in */
|
||||||
chmod("/var/log/wtmp", 0664);
|
create("/var/log/wtmp", 0644, 0, gid); /* Login history */
|
||||||
chown("/var/log/wtmp", 0, gid);
|
create("/var/log/btmp", 0600, 0, gid); /* Failed logins */
|
||||||
touch("/var/log/btmp");
|
create("/var/log/lastlog", 0644, 0, gid);
|
||||||
chmod("/var/log/btmp", 0600);
|
|
||||||
chown("/var/log/btmp", 0, gid);
|
|
||||||
touch("/var/log/lastlog");
|
|
||||||
chmod("/var/log/lastlog", 0664);
|
|
||||||
chown("/var/log/lastlog", 0, gid);
|
|
||||||
|
|
||||||
/* Set BOOT_TIME UTMP entry */
|
/* Set BOOT_TIME UTMP entry */
|
||||||
utmp_set_boot();
|
utmp_set_boot();
|
||||||
|
|||||||
Reference in new issue
Block a user