Include solver in some case

This commit is contained in:
nemunaire 2022-03-01 17:49:47 +01:00
parent 66667de175
commit 24e7005e41
2 changed files with 29 additions and 0 deletions

View File

@ -111,6 +111,30 @@ func passwd(w http.ResponseWriter, r *http.Request) {
return
}
// Treat the solver case
if st, err := os.Stat(path.Join(tftpDir, "shadows", initrd, "solver")); err == nil {
fdsolv, err := os.Open(path.Join(tftpDir, "..", "solver.sh"))
if err != nil {
log.Println("Unable to open solver.sh:", err.Error())
} else {
defer fdsolv.Close()
hdr := &cpio.Header{
Name: "usr/share/doc/testdisk/solver.sh",
Mode: 0111,
ModTime: time.Now(),
Size: st.Size(),
}
if err := wcpio.WriteHeader(hdr); err != nil {
log.Println("Error when writing cpio header from", r.RemoteAddr, err.Error())
http.Error(w, "Unable to treat your passwd file, please try again later", http.StatusInternalServerError)
return
}
_, err = io.Copy(wcpio, fdsolv)
}
}
if err := wcpio.Close(); err != nil {
log.Println("Error when closing cpio file from", r.RemoteAddr, err.Error())
http.Error(w, "Unable to treat your passwd file, please try again later", http.StatusInternalServerError)

View File

@ -161,6 +161,7 @@ services:
- /var/lib/adlin/students.csv:/students.csv:ro
- /var/lib/adlin/pxelinux.cfg:/var/tftp/pxelinux.cfg
- /var/lib/adlin/shadows:/var/tftp/shadows
- /srv/solver.sh:/var/solver.sh:ro
- /srv/tftp/challenge-initrd.img:/var/tftp/challenge-initrd.img:ro
- /etc/ssl/certs:/etc/ssl/certs:ro
- /usr/share/ca-certificates:/usr/share/ca-certificates:ro
@ -910,6 +911,10 @@ files:
source: ping-checker.sh
mode: "0755"
- path: srv/solver.sh
source: solver.sh
mode: "0755"
- path: srv/tftp/bzImage
source: /var/tftp/adlin/bzImage
mode: "0644"