mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-24 21:34:08 +03:00
copy: simplify error paths when creating temporary files
This commit is contained in:
parent
e6283cbf48
commit
e1aec57dd1
@ -1147,24 +1147,24 @@ int copy_file_atomic_full(
|
|||||||
* writing it. */
|
* writing it. */
|
||||||
|
|
||||||
if (copy_flags & COPY_REPLACE) {
|
if (copy_flags & COPY_REPLACE) {
|
||||||
r = tempfn_random(to, NULL, &t);
|
_cleanup_free_ char *f = NULL;
|
||||||
|
|
||||||
|
r = tempfn_random(to, NULL, &f);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (copy_flags & COPY_MAC_CREATE) {
|
if (copy_flags & COPY_MAC_CREATE) {
|
||||||
r = mac_selinux_create_file_prepare(to, S_IFREG);
|
r = mac_selinux_create_file_prepare(to, S_IFREG);
|
||||||
if (r < 0) {
|
if (r < 0)
|
||||||
t = mfree(t);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fdt = open(t, O_CREAT|O_EXCL|O_NOFOLLOW|O_NOCTTY|O_WRONLY|O_CLOEXEC, 0600);
|
fdt = open(f, O_CREAT|O_EXCL|O_NOFOLLOW|O_NOCTTY|O_WRONLY|O_CLOEXEC, 0600);
|
||||||
if (copy_flags & COPY_MAC_CREATE)
|
if (copy_flags & COPY_MAC_CREATE)
|
||||||
mac_selinux_create_file_clear();
|
mac_selinux_create_file_clear();
|
||||||
if (fdt < 0) {
|
if (fdt < 0)
|
||||||
t = mfree(t);
|
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
|
||||||
|
t = TAKE_PTR(f);
|
||||||
} else {
|
} else {
|
||||||
if (copy_flags & COPY_MAC_CREATE) {
|
if (copy_flags & COPY_MAC_CREATE) {
|
||||||
r = mac_selinux_create_file_prepare(to, S_IFREG);
|
r = mac_selinux_create_file_prepare(to, S_IFREG);
|
||||||
|
Loading…
Reference in New Issue
Block a user