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 578789 Details for
Bug 814427
Unexpected /sbin/securetty failure with read-only root file system
[?]
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]
better patch
diff (text/plain), 2.93 KB, created by
Bill Nottingham
on 2012-04-19 21:09:45 UTC
(
hide
)
Description:
better patch
Filename:
MIME Type:
Creator:
Bill Nottingham
Created:
2012-04-19 21:09:45 UTC
Size:
2.93 KB
patch
obsolete
>diff --git a/src/securetty.c b/src/securetty.c >index 9ec8e7e..a4768e3 100644 >--- a/src/securetty.c >+++ b/src/securetty.c >@@ -18,6 +18,7 @@ > > #include <errno.h> > #include <fcntl.h> >+#include <limits.h> > #include <signal.h> > #include <stdio.h> > #include <stdlib.h> >@@ -25,6 +26,7 @@ > #include <syslog.h> > #include <unistd.h> > >+#include <sys/mman.h> > #include <sys/types.h> > #include <sys/stat.h> > >@@ -66,29 +68,10 @@ int open_and_lock_securetty() { > > int rewrite_securetty(char *terminal) { > int fd; >- char *buf, *pos; >- struct stat sbuf; > > fd = open_and_lock_securetty(); > if (fd == -1) > return 1; >- if (fstat(fd, &sbuf) == -1) { >- close(fd); >- syslog(LOG_ERR, "Couldn't stat /etc/securetty: %s",strerror(errno)); >- return 1; >- } >- buf = malloc(sbuf.st_size + 1); >- if (read(fd, buf, sbuf.st_size) != sbuf.st_size) { >- close(fd); >- syslog(LOG_ERR, "Couldn't read /etc/securetty: %s",strerror(errno)); >- return 1; >- } >- if (!strncmp(buf,terminal,strlen(terminal)) && buf[strlen(terminal)] == '\n') >- goto out_ok; >- if ((pos = strstr(buf, terminal))) { >- if (pos[strlen(terminal)] == '\n' && *(pos-1) == '\n') >- goto out_ok; >- } > if (lseek(fd, 0, SEEK_END) == -1) { > close(fd); > syslog(LOG_ERR, "Couldn't seek to end of /etc/securetty: %s",strerror(errno)); >@@ -96,16 +79,49 @@ int rewrite_securetty(char *terminal) { > } > write(fd, terminal, strlen(terminal)); > write(fd, "\n", 1); >-out_ok: > close(fd); > return 0; > } > >+int check_securetty(char *terminal) { >+ int fd, rc = 1; >+ char *buf, term[PATH_MAX]; >+ struct stat sb; >+ >+ fd = open("/etc/securetty", O_RDONLY); >+ if (fd == -1) >+ goto out; >+ fstat(fd, &sb); >+ buf = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0); >+ if (buf == ((caddr_t) -1)) { >+ close(fd); >+ return 1; >+ } >+ snprintf(term,PATH_MAX,"%s\n",terminal); >+ if (!strncmp(buf,term,strlen(term))) { >+ rc = 0; >+ goto out_unmap; >+ } >+ snprintf(term,PATH_MAX,"\n%s\n",terminal); >+ if (strstr(buf,term)) { >+ rc = 0; >+ goto out_unmap; >+ } >+out_unmap: >+ munmap(buf, sb.st_size); >+out: >+ close(fd); >+ return rc; >+} >+ > int main(int argc, char **argv) { > if (argc < 2 ) { > fprintf(stderr, "Usage: securetty <device>\n"); > exit(1); > } > openlog("securetty", LOG_CONS, LOG_DAEMON); >- return rewrite_securetty(argv[1]); >+ if (check_securetty(argv[1])) >+ return rewrite_securetty(argv[1]); >+ else >+ return 0; > }
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 814427
:
578786
| 578789