main: ensure NMSTATEDIR exists (bgo #689744)

For OSTree/gnome-ostree, the model chosen for /var is that services
are responsible for creating any data they need in /var at runtime.

Call g_mkdir_with_parents() to ensure NMSTATEDIR exists.

https://bugzilla.gnome.org/show_bug.cgi?id=689744

Based on Colin Walters' patch.
This commit is contained in:
Jiří Klimeš 2012-12-06 16:33:52 +01:00
parent 76e8f60212
commit e7add58aad

View file

@ -435,6 +435,12 @@ main (int argc, char *argv[])
exit (1);
}
/* Ensure state directory exists */
if (g_mkdir_with_parents (NMSTATEDIR, 0755) != 0) {
nm_log_err (LOGD_CORE, "Cannot create '%s': %s", NMSTATEDIR, strerror (errno));
exit (1);
}
pidfile = pidfile ? pidfile : g_strdup (NM_DEFAULT_PID_FILE);
state_file = state_file ? state_file : g_strdup (NM_DEFAULT_SYSTEM_STATE_FILE);