go bindings for username lookup by UID
parent
860effb91c
commit
393832889d
8
Makefile
8
Makefile
|
@ -3,8 +3,9 @@
|
||||||
check_certificate_files := $(wildcard src/go/checkCertificate/*.go)
|
check_certificate_files := $(wildcard src/go/checkCertificate/*.go)
|
||||||
check_certificate_signatures_files := $(wildcard src/go/checkCertSignatures/*.go)
|
check_certificate_signatures_files := $(wildcard src/go/checkCertSignatures/*.go)
|
||||||
storage_files := $(wildcard src/go/storage/*.go)
|
storage_files := $(wildcard src/go/storage/*.go)
|
||||||
|
get_user_by_uid_files := $(wildcard src/go/getUserByUid/*.go)
|
||||||
|
|
||||||
all: check_certificate check_cert_signatures storage typescript
|
all: check_certificate check_cert_signatures storage getUserByUid typescript
|
||||||
|
|
||||||
check_certificate:
|
check_certificate:
|
||||||
HOME=/root go build -ldflags="-s -w" -o dist/bin/checkCertificate ${check_certificate_files}
|
HOME=/root go build -ldflags="-s -w" -o dist/bin/checkCertificate ${check_certificate_files}
|
||||||
|
@ -21,5 +22,10 @@ storage:
|
||||||
@chmod 740 dist/bin/storage
|
@chmod 740 dist/bin/storage
|
||||||
file dist/bin/storage
|
file dist/bin/storage
|
||||||
|
|
||||||
|
getUserByUid:
|
||||||
|
HOME=/root go build -ldflags="-s -w" dist/bin/getUserByUid ${storage_files}
|
||||||
|
@chmod 740 dist/bin/getUserByUid
|
||||||
|
file dist/bin/getUserByUid
|
||||||
|
|
||||||
typescript:
|
typescript:
|
||||||
tsc -p ./tsconfig.json
|
tsc -p ./tsconfig.json
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { Client } from '..';
|
||||||
|
|
||||||
|
export default async function getUserByUid(client: Client, uid: number): Promise<string | null> {
|
||||||
|
const res = await client.util.exec(`${__dirname}/../bin/getUserByUid ${uid}`);
|
||||||
|
if (res === '-1') return null;
|
||||||
|
return res.trim();
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
export { default as checkLock, clear as clearLock } from '../intervals/checkLock';
|
export { default as checkLock, clear as clearLock } from '../intervals/checkLock';
|
||||||
export { default as dataConversion } from './dataConversion';
|
export { default as dataConversion } from './dataConversion';
|
||||||
export { default as existingLimitsSetup } from './existingLimitsSetup';
|
export { default as existingLimitsSetup } from './existingLimitsSetup';
|
||||||
|
export { default as getUserByUid } from './getUserByUid';
|
||||||
// export { default as checkSS, clear as clearSS } from './checkSS';
|
// export { default as checkSS, clear as clearSS } from './checkSS';
|
||||||
export { default as parseCertificate, Certificate } from './parseCertificate';
|
export { default as parseCertificate, Certificate } from './parseCertificate';
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if len(os.Args) > 1 {
|
||||||
|
fmt.Println("-1")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
userInfo, err := user.LookupId(os.Args[1])
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("-1")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
fmt.Printf("%s", userInfo.Username)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
Loading…
Reference in New Issue