1
0
Fork 0

go bindings for username lookup by UID

refactor/models
Matthew 2020-05-22 21:56:56 -04:00
parent 860effb91c
commit 393832889d
No known key found for this signature in database
GPG Key ID: D499B75C1390E321
4 changed files with 36 additions and 1 deletions

View File

@ -3,8 +3,9 @@
check_certificate_files := $(wildcard src/go/checkCertificate/*.go)
check_certificate_signatures_files := $(wildcard src/go/checkCertSignatures/*.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:
HOME=/root go build -ldflags="-s -w" -o dist/bin/checkCertificate ${check_certificate_files}
@ -21,5 +22,10 @@ storage:
@chmod 740 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:
tsc -p ./tsconfig.json

View File

@ -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();
}

View File

@ -1,5 +1,6 @@
export { default as checkLock, clear as clearLock } from '../intervals/checkLock';
export { default as dataConversion } from './dataConversion';
export { default as existingLimitsSetup } from './existingLimitsSetup';
export { default as getUserByUid } from './getUserByUid';
// export { default as checkSS, clear as clearSS } from './checkSS';
export { default as parseCertificate, Certificate } from './parseCertificate';

View File

@ -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)
}