diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c index af9e07c1ab..d2075f5bed 100644 --- a/src/libostree/ostree-sysroot.c +++ b/src/libostree/ostree-sysroot.c @@ -2240,10 +2240,19 @@ ostree_sysroot_deployment_unlock (OstreeSysroot *self, OstreeDeployment *deploym g_autofree char *devpath = unlocked_state == OSTREE_DEPLOYMENT_UNLOCKED_DEVELOPMENT ? _ostree_sysroot_get_runstate_path ( - deployment, _OSTREE_SYSROOT_DEPLOYMENT_RUNSTATE_FLAG_DEVELOPMENT) + deployment, _OSTREE_SYSROOT_DEPLOYMENT_RUNSTATE_FLAG_DEVELOPMENT) : _ostree_sysroot_get_runstate_path ( - deployment, _OSTREE_SYSROOT_DEPLOYMENT_RUNSTATE_FLAG_TRANSIENT); - g_autofree char *devpath_parent = dirname (g_strdup (devpath)); + deployment, _OSTREE_SYSROOT_DEPLOYMENT_RUNSTATE_FLAG_TRANSIENT); + + g_autofree char *devpath_parent = ""; + if (devpath[strlen (devpath) - 1] == G_DIR_SEPARATOR) + { + g_autofree char *modifed_devpath = g_strdup (devpath); + modifed_devpath[strlen (modifed_devpath) - 1] = '\0'; + devpath_parent = g_path_get_dirname (modifed_devpath); + } + else + devpath_parent = g_path_get_dirname (devpath); if (!glnx_shutil_mkdir_p_at (AT_FDCWD, devpath_parent, 0755, cancellable, error)) return FALSE;