Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 431162 Details for
Bug 580458
x11-misc/slim: open /var/log/slim.log close-on-exec
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch that causes /var/log/slim.log to be set close-on-exec
slim_cloexec.path (text/plain), 1.65 KB, created by
Matthias Gerstner
on 2016-04-18 19:24:28 UTC
(
hide
)
Description:
Patch that causes /var/log/slim.log to be set close-on-exec
Filename:
MIME Type:
Creator:
Matthias Gerstner
Created:
2016-04-18 19:24:28 UTC
Size:
1.65 KB
patch
obsolete
>diff -r -u slim-1.3.6/log.cpp slim-1.3.6.new/log.cpp >--- slim-1.3.6/log.cpp 2013-10-02 00:38:05.000000000 +0200 >+++ slim-1.3.6.new/log.cpp 2016-02-12 23:31:58.229257277 +0100 >@@ -1,23 +1,37 @@ > #include "log.h" > #include <iostream> > >+#include <sys/types.h> >+#include <sys/stat.h> >+#include <fcntl.h> >+ > bool > LogUnit::openLog(const char * filename) > { >- if (logFile.is_open()) { >+ if ( closeLog() ) >+ { > cerr << APPNAME > << ": opening a new Log file, while another is already open" > << endl; >- logFile.close(); > } >- logFile.open(filename, ios_base::app); >+ >+ // go through quite some trouble to get a close-on-exec file >+ // descriptor and wrapping it into an ostream object for easing >+ // logging >+ >+ fileBuffer.open( filename, ios_base::app ); >+ fcntl(fileBuffer.fd(), F_SETFD, FD_CLOEXEC); >+ logFile.rdbuf( &fileBuffer ); > > return !(logFile.fail()); > } > >-void >+bool > LogUnit::closeLog() > { >- if (logFile.is_open()) >- logFile.close(); >+ if( ! fileBuffer.is_open() ) >+ return false; >+ >+ fileBuffer.close(); >+ return true; > } >diff -r -u slim-1.3.6/log.h slim-1.3.6.new/log.h >--- slim-1.3.6/log.h 2013-10-02 00:38:05.000000000 +0200 >+++ slim-1.3.6.new/log.h 2016-02-12 23:31:09.797498557 +0100 >@@ -8,16 +8,20 @@ > #include "PAM.h" > #endif > #include "const.h" >+#include <ext/stdio_filebuf.h> > #include <fstream> > > using namespace std; > > static class LogUnit { >- ofstream logFile; >+ typedef __gnu_cxx::stdio_filebuf<char> FileDescBuffer; >+ FileDescBuffer fileBuffer; >+ ostream logFile; > public: > bool openLog(const char * filename); >- void closeLog(); >+ bool closeLog(); > >+ LogUnit() : logFile(&fileBuffer) { } > ~LogUnit() { closeLog(); } > > template<typename Type>
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 580458
: 431162