CC = cc
AR = ar
-CFLAGS = -I $(PWD)/Common
+CFLAGS = -I $(PWD)/Common -DHAS_PLAIN_AUTH -DHAS_NONE_AUTH
LDFLAGS =
LIBS =
EXEC =
--- /dev/null
+# $Id$
+
+CC = cc
+AR = ar
+CFLAGS = -I $(PWD)/Common -DHAS_PLAIN_AUTH -DHAS_NONE_AUTH -DHAS_PAM_AUTH -DHAS_CRYPT_AUTH
+LDFLAGS =
+LIBS = -lcrypt -lpam
+EXEC =
CC = i686-w64-mingw32-gcc
AR = i686-w64-mingw32-ar
-CFLAGS = -I $(PWD)/Common
+CFLAGS = -I $(PWD)/Common -DHAS_PLAIN_AUTH -DHAS_NONE_AUTH
LDFLAGS =
LIBS = -lws2_32
EXEC = .exe
CC = x86_64-w64-mingw32-gcc
AR = x86_64-w64-mingw32-ar
-CFLAGS = -I $(PWD)/Common
+CFLAGS = -I $(PWD)/Common -DHAS_PLAIN_AUTH -DHAS_NONE_AUTH
LDFLAGS =
LIBS = -lws2_32
EXEC = .exe
.PHONY: all clean
.SUFFIXES: .c .o
-OBJS = main.o server.o
+OBJS = main.o server.o auth.o config.o
OBJS += ../Common/common.a
all: rbuild-server$(EXEC)
--- /dev/null
+/* $Id$ */
+
+#include "rbs_auth.h"
+
+#ifdef HAS_PAM_AUTH
+#include <security/pam_appl.h>
+#endif
+
+const char* rbs_pam_auth =
+#ifdef HAS_PAM_AUTH
+"available"
+#else
+"not available"
+#endif
+;
+
+const char* rbs_plain_auth =
+#ifdef HAS_PLAIN_AUTH
+"available"
+#else
+"not available"
+#endif
+;
+
+const char* rbs_crypt_auth =
+#ifdef HAS_CRYPT_AUTH
+"available"
+#else
+"not available"
+#endif
+;
+
+const char* rbs_none_auth =
+#ifdef HAS_NONE_AUTH
+"available"
+#else
+"not available"
+#endif
+;
--- /dev/null
+/* $Id$ */
+
+#include "rbs_config.h"
+
+#include <stdio.h>
+
+#include <cm_bool.h>
+
+extern char* rbs_config;
+
+void rbs_config_init(void){
+}
+
+CMBOOL rbs_config_parse(void){
+ FILE* f = fopen(rbs_config, "r");
+ if(f != NULL){
+ fclose(f);
+ return CMTRUE;
+ }else{
+ fprintf(stderr, "Could not open the config\n");
+ return CMFALSE;
+ }
+}
/* $Id$ */
+#include "../config.h"
+
#include <stdio.h>
#include <string.h>
#include "rbs_server.h"
+#include "rbs_config.h"
#include <cm_bool.h>
extern CMBOOL run_inetd;
+char* rbs_config = NULL;
+extern const char* rbs_none_auth;
+extern const char* rbs_crypt_auth;
+extern const char* rbs_plain_auth;
+extern const char* rbs_pam_auth;
+
int main(int argc, char** argv){
int i;
for(i = 1; i < argc; i++){
fprintf(stderr, "Missing argument\n");
return 1;
}
+ rbs_config = argv[i];
+ }else if(strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "-V") == 0){
+ printf("rbuild-server version %s\n", RBUILD_VERSION);
+ printf("Authentication methods:\n");
+ printf("\tNone : %s\n", rbs_none_auth);
+ printf("\tCrypt : %s\n", rbs_crypt_auth);
+ printf("\tPlain : %s\n", rbs_plain_auth);
+ printf("\tPAM : %s\n", rbs_pam_auth);
+ return 0;
}else{
fprintf(stderr, "Unknown option: %s\n", argv[i]);
return 1;
}else{
}
}
+ if(rbs_config == NULL){
+ fprintf(stderr, "Config is required\n");
+ return 1;
+ }
+ rbs_config_init();
+ if(!rbs_config_parse()){
+ fprintf(stderr, "Failed to parse config\n");
+ return 1;
+ }
if(!rbs_server_init()){
fprintf(stderr, "Failed to initialize\n");
return 1;
--- /dev/null
+/* $Id$ */
+
+#ifndef __RBS_AUTH_H__
+#define __RBS_AUTH_H__
+
+#endif
--- /dev/null
+/* $Id$ */
+
+#ifndef __RBS_CONFIG_H__
+#define __RBS_CONFIG_H__
+
+#include <cm_bool.h>
+
+void rbs_config_init(void);
+CMBOOL rbs_config_parse(void);
+
+#endif
/* $Id$ */
+#include "../config.h"
+
#include "rbs_server.h"
+#include "rbs_auth.h"
#include <stdlib.h>
#include <stdio.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
+#include <sys/select.h>
#endif
+#include <cm_string.h>
#include <cm_bool.h>
+char* ready;
CMBOOL run_inetd = CMFALSE;
int server_socket;
int port = 7980;
sock = *(int*)sockptr;
free(sockptr);
}
- rbs_write(sock, "Hello\n", 6);
+ rbs_write(sock, "READY ", 6);
+ rbs_write(sock, ready, strlen(ready));
+ rbs_write(sock, "\n", 1);
+
+ while(1){
+ fd_set rfds;
+ struct timeval tv;
+ int ret;
+
+ FD_ZERO(&rfds);
+ FD_SET(sock, &rfds);
+ tv.tv_sec = 5;
+ tv.tv_usec = 0;
+
+ ret = select(1, &rfds, NULL, NULL, &tv);
+
+ if(ret < 0){
+ break;
+ }else if(ret == 0){
+ rbs_write(sock, "TIMEOUT\n", 8);
+ break;
+ }else{
+ }
+ }
rbs_close(sock);
#ifdef WINSOCK
if(run_inetd){
rbs_server_handler(NULL);
}else{
+ ready = cm_strdup(RBUILD_VERSION);
#ifndef WINSOCK
signal(SIGCHLD, SIG_IGN);
#endif