login-validator: Add gzip compression
This commit is contained in:
parent
aa753b4075
commit
f317d11fac
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"compress/gzip"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
@ -53,7 +54,8 @@ func passwd(w http.ResponseWriter, r *http.Request) {
|
||||
defer fd.Close()
|
||||
|
||||
// Generate the new cpio archive
|
||||
wcpio := cpio.NewWriter(fd)
|
||||
zw := gzip.NewWriter(fd)
|
||||
wcpio := cpio.NewWriter(zw)
|
||||
|
||||
hdr := &cpio.Header{
|
||||
Name: "etc/shadow",
|
||||
@ -83,6 +85,12 @@ func passwd(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := zw.Close(); err != nil {
|
||||
log.Println("Error when closing gzip file from", r.RemoteAddr, err.Error())
|
||||
http.Error(w, "Unable to treat your passwd file, please try again later", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
log.Println("Registered shadow from", r.RemoteAddr)
|
||||
http.Error(w, "Success", http.StatusOK)
|
||||
}
|
||||
|
Reference in New Issue
Block a user