Skip to content

Commit

Permalink
Support Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
  • Loading branch information
Jianhui Zhao committed Aug 22, 2018
1 parent 00ea318 commit 917c7ba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions login.go → login_linux.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"unsafe"
"syscall"
)

/*
Expand Down Expand Up @@ -40,6 +41,10 @@ static bool login(const char *username, const char *password)
*/
import "C"

func checkUser() bool {
return syscall.Getuid() == 0
}

func login(username, password string) bool {
c_username := C.CString(username)
c_password := C.CString(password)
Expand Down
9 changes: 9 additions & 0 deletions login_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

func checkUser() bool {
return true
}

func login(username, password string) bool {
return true
}
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"time"
"runtime"
"strconv"
"syscall"
"crypto/md5"
"math/rand"
"net/http"
Expand Down Expand Up @@ -105,7 +104,7 @@ func main() {
cert := flag.String("cert", "", "certFile Path")
key := flag.String("key", "", "keyFile Path")

if syscall.Getuid() != 0 {
if !checkUser() {
rlog.Println("Operation not permitted")
os.Exit(1)
}
Expand Down

0 comments on commit 917c7ba

Please sign in to comment.