Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 603970 Details for
Bug 847339
logrotate ACL fix race condition
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
patch
logrotate-3.7.8-acl-race.patch (text/plain), 3.97 KB, created by
Jan Kaluža
on 2012-08-13 12:07:27 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Jan Kaluža
Created:
2012-08-13 12:07:27 UTC
Size:
3.97 KB
patch
obsolete
>diff --git a/logrotate.c b/logrotate.c >index 8623bc3..fbbcc1a 100644 >--- a/logrotate.c >+++ b/logrotate.c >@@ -24,9 +24,13 @@ int selinux_enforce = 0; > > #ifdef WITH_ACL > #include "sys/acl.h" >-static acl_t prev_acl = NULL; >+#define acl_type acl_t >+#else >+#define acl_type void * > #endif > >+static acl_type prev_acl = NULL; >+ > #include "basenames.h" > #include "log.h" > #include "logrotate.h" >@@ -224,7 +228,7 @@ static int runScript(char *logfn, char *script) > return rc; > } > >-int createOutputFile(char *fileName, int flags, struct stat *sb) >+int createOutputFile(char *fileName, int flags, struct stat *sb, acl_type acl) > { > int fd; > char template[PATH_MAX + 1]; >@@ -248,6 +252,18 @@ int createOutputFile(char *fileName, int flags, struct stat *sb) > return -1; > } > >+#ifdef WITH_ACL >+ if (acl && acl_set_fd(fd, acl) == -1) { >+ if (errno != ENOTSUP) { >+ message(MESS_ERROR, "setting ACL for %s: %s\n", >+ fileName, strerror(errno)); >+ acl_free(prev_acl); >+ close(fd); >+ return -1; >+ } >+ } >+#endif >+ > if (fchmod(fd, sb->st_mode)) { > message(MESS_ERROR, "error setting mode of %s: %s\n", > fileName, strerror(errno)); >@@ -367,14 +383,7 @@ static int compressLogFile(char *name, struct logInfo *log, struct stat *sb) > message(MESS_ERROR, "unable to open %s for compression\n", name); > return 1; > } >- >- outFile = >- createOutputFile(compressedName, O_RDWR | O_CREAT | O_TRUNC, sb); >- if (outFile < 0) { >- close(inFile); >- return 1; >- } >- >+ > #ifdef WITH_ACL > if ((prev_acl = acl_get_fd(inFile)) == NULL) { > if (errno != ENOTSUP) { >@@ -385,18 +394,18 @@ static int compressLogFile(char *name, struct logInfo *log, struct stat *sb) > return 1; > } > } >+#endif >+ >+ outFile = >+ createOutputFile(compressedName, O_RDWR | O_CREAT | O_TRUNC, sb, prev_acl); >+ if (outFile < 0) { >+ prev_acl = NULL; >+ close(inFile); >+ return 1; >+ } >+ >+#ifdef WITH_ACL > if (prev_acl) { >- if (acl_set_fd(outFile, prev_acl) == -1) { >- if (errno != ENOTSUP) { >- message(MESS_ERROR, "setting ACL for %s: %s\n", >- compressedName, strerror(errno)); >- acl_free(prev_acl); >- prev_acl = NULL; >- close(inFile); >- close(outFile); >- return 1; >- } >- } > acl_free(prev_acl); > prev_acl = NULL; > } >@@ -579,7 +588,7 @@ static int copyTruncate(char *currLog, char *saveLog, struct stat *sb, > } > #endif /* WITH_ACL */ > fdsave = >- createOutputFile(saveLog, O_WRONLY | O_CREAT | O_TRUNC, sb); >+ createOutputFile(saveLog, O_WRONLY | O_CREAT | O_TRUNC, sb, prev_acl); > #ifdef WITH_SELINUX > if (selinux_enabled) { > setfscreatecon_raw(prev_context); >@@ -590,30 +599,10 @@ static int copyTruncate(char *currLog, char *saveLog, struct stat *sb, > if (fdsave < 0) { > close(fdcurr); > #ifdef WITH_ACL >- if (prev_acl) { >- acl_free(prev_acl); >- prev_acl = NULL; >- } >+ prev_acl = NULL; > #endif /* WITH_ACL */ > return 1; > } >-#ifdef WITH_ACL >- if (prev_acl) { >- if (acl_set_fd(fdsave, prev_acl) == -1) { >- if (errno != ENOTSUP) { >- message(MESS_ERROR, "setting ACL for %s: %s\n", >- saveLog, strerror(errno)); >- acl_free(prev_acl); >- prev_acl = NULL; >- close(fdsave); >- close(fdcurr); >- return 1; >- } >- } >- acl_free(prev_acl); >- prev_acl = NULL; >- } >-#endif /* WITH_ACL */ > > while ((cnt = read(fdcurr, buf, sizeof(buf))) > 0) { > if (write(fdsave, buf, cnt) != cnt) { >@@ -1257,23 +1246,12 @@ int rotateSingleLog(struct logInfo *log, int logNum, struct logState *state, > if (!debug) { > if (!hasErrors) { > fd = createOutputFile(log->files[logNum], O_CREAT | O_RDWR, >- &sb); >- if (fd < 0) >+ &sb, prev_acl); >+ if (fd < 0) { > hasErrors = 1; >+ prev_acl = NULL; >+ } > else { >-#ifdef WITH_ACL >- if (prev_acl) { >- if (acl_set_fd(fd, prev_acl) == -1) { >- if (errno != ENOTSUP) { >- message(MESS_ERROR, "setting ACL for %s: %s\n", >- log->files[logNum], strerror(errno)); >- hasErrors = 1; >- } >- } >- acl_free(prev_acl); >- prev_acl = NULL; >- } >-#endif /* WITH_ACL */ > close(fd); > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 847339
: 603970