made it a bit more openbsd friendly
This commit is contained in:
parent
e38a69d010
commit
c51e53bd89
16
Makefile
16
Makefile
|
@ -1,20 +1,14 @@
|
|||
TARGET ?= tildebin
|
||||
SRC_DIRS ?= ./
|
||||
|
||||
CFLAGS := -g -Wall -Wpedantic
|
||||
CFLAGS := -g -Wall -Wextra
|
||||
|
||||
SRCS := $(shell find $(SRC_DIRS) -name *.c)
|
||||
OBJS := $(addsuffix .o,$(basename $(SRCS)))
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
|
||||
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
|
||||
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
||||
SRCS := tildebin.c
|
||||
OBJS := tildebin.o
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@ $(LOADLIBES) $(LDLIBS)
|
||||
$(CC) $(CFLAGS) $(OBJS) -o $@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(RM) $(TARGET) $(OBJS) $(DEPS)
|
||||
|
||||
-include $(DEPS)
|
||||
rm $(TARGET) $(OBJS)
|
||||
|
|
2
tb.sh
2
tb.sh
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
SOCKET_PATH=""
|
||||
if [ -z "$TILDEBIN_SOCK" ]; then
|
||||
|
|
20
tildebin.c
20
tildebin.c
|
@ -12,6 +12,10 @@
|
|||
#define __USE_GNU
|
||||
#endif
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
#include <sys/ucred.h>
|
||||
#endif
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -103,7 +107,6 @@ get_uinfo( int fd, struct uinfo *uinfo )
|
|||
{
|
||||
memset(uinfo, 0, sizeof(*uinfo));
|
||||
|
||||
#ifdef __linux__
|
||||
int len, ret;
|
||||
struct passwd* pw;
|
||||
struct ucred uc;
|
||||
|
@ -115,6 +118,7 @@ get_uinfo( int fd, struct uinfo *uinfo )
|
|||
return -1;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
if((pw = getpwuid(uc.uid)) == NULL)
|
||||
{
|
||||
ERROR("connection with invalid uid %d", uc.uid);
|
||||
|
@ -124,11 +128,21 @@ get_uinfo( int fd, struct uinfo *uinfo )
|
|||
uinfo->uid = uc.uid;
|
||||
uinfo->gid = uc.gid;
|
||||
strncpy(uinfo->name, pw->pw_name, GET_LEN(uinfo->name));
|
||||
return ret;
|
||||
#elif __OpenBSD__
|
||||
if((pw = getpwuid(uc.cr_uid)) == NULL)
|
||||
{
|
||||
ERROR("connection with invalid uid %d", uc.cr_uid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
uinfo->uid = uc.cr_uid;
|
||||
uinfo->gid = uc.cr_gid;
|
||||
strncpy(uinfo->name, pw->pw_name, GET_LEN(uinfo->name));
|
||||
#else
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// I'm not even going to bother commenting this mess, it's
|
||||
|
|
Loading…
Reference in New Issue