Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Ian Eiloart
Sympl
Commits
7741f22c
Commit
7741f22c
authored
Apr 21, 2016
by
Steve Kemp
Browse files
Change the UID/GID of a logfile via filehandle.
This is better than using a path.
parent
fca3639e
Changes
1
Hide whitespace changes
Inline
Side-by-side
httpd-logger/symbiosis-httpd-logger.go
View file @
7741f22c
...
...
@@ -55,13 +55,11 @@ import (
//
var
handles
=
make
(
map
[
string
]
*
os
.
File
)
//
// The number of files we'll keep open at any one time.
//
var
files_count
=
100
//
// Setup a handler for SIGHUP which will close all of our
// open files.
...
...
@@ -125,7 +123,6 @@ func close_logfiles() {
//
func
safeOpen
(
path
string
)
*
os
.
File
{
//
// If we have too many open files then close them all.
//
...
...
@@ -335,7 +332,7 @@ func main() {
//
if
handles
[
default_file
]
!=
nil
{
handles
[
default_file
]
.
WriteString
(
log
+
"
\n
"
)
}
}
//
// The line will contain the vhost-name as the initial
...
...
@@ -415,7 +412,9 @@ func main() {
// Ensure the UID/GID of the logfile match that on the
// virtual-hosts' directory
os
.
Chown
(
logfile
,
int
(
uid
),
int
(
gid
))
if
h
!=
nil
{
h
.
Chown
(
int
(
uid
),
int
(
gid
))
}
}
//
...
...
@@ -424,7 +423,7 @@ func main() {
//
if
h
!=
nil
{
h
.
WriteString
(
rest
+
"
\n
"
)
}
}
}
// Check for errors during `Scan`. End of file is
...
...
@@ -437,6 +436,6 @@ func main() {
//
// Close all our open handles.
//
close_logfiles
()
close_logfiles
()
os
.
Exit
(
0
)
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment