<commit_before>/******************************************************************************
gram_gatekeeper.c
 
Description:
    Resource Managemant gatekeeper.
 
CVS Information:
 
    $Source$
    $Date$
    $Revision$
    $Author$

 This source file has been modified by <NAME> (<EMAIL>)
 with extensions for UNICOS.
 September 1998
 
******************************************************************************/

/******************************************************************************
                             Include header files
******************************************************************************/
#if defined(_AIX32) && !defined(_ALL_SOURCE)
#define _ALL_SOURCE
#endif
#include "globus_config.h"
#include "globus_i_gram_version.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <fcntl.h>
#include <pwd.h>
#include <sys/param.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/socket.h>
#include <syslog.h>
#include <netdb.h>
#include <netinet/in.h>
#if defined (HAVE_NETINET_TCP_H)
#   include <netinet/tcp.h>
#endif
#include <arpa/inet.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/signal.h>
#include <sys/wait.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif

#ifdef GSS_AUTHENTICATION
#include "globus_gss_assist.h"
#include <gssapi.h>
#endif

#if defined(TARGET_ARCH_SOLARIS)
#include <termios.h>
#endif

#if defined(TARGET_ARCH_AIX)
#define netlen_t size_t
#else
#define netlen_t int
#endif

#include <strings.h>

#include <arpa/inet.h> /* for inet_ntoa() */

#ifdef BSD
#include <strings.h>
#endif

#ifdef SYSV
#include <string.h>
#endif

#if defined(TARGET_ARCH_CRAYT3E)
#include "unicos.h"
#endif

#if defined(HAVE_PROJ_H) && defined(TARGET_ARCH_IRIX)
#include <proj.h>
#endif

#if !defined(MAXPATHLEN) 
#   define MAXPATHLEN PATH_MAX
#endif

/******************************************************************************
                               Type definitions
******************************************************************************/

/******************************************************************************
                          Module specific prototypes
******************************************************************************/
static void 
doit();
static int 
logging_startup(void);
static int
logging_phase2(void);
static void 
failure(char *s);
static void 
notice(int, char *s);
static int 
net_accept(int socket);
static void 
net_setup_listener(int backlog, int *port, int *socket);
static void 
error_check(int val, char *string);
static char 
*timestamp(void);
static int
tokenize(char * command, char ** args, int * n);

static char *
genfilename(char * prefix, char * path, char * sufix);

/*
 * GSSAPI - credential handle for this process
 */

static gss_cred_id_t credential_handle = GSS_C_NO_CREDENTIAL;

/******************************************************************************
                       Define module specific variables
******************************************************************************/
#define MAXARGS 256
#define DEFAULT_PORT 754
#define MAX_MESSAGE_LENGTH 100000
#ifndef GRAM_K5_EXE
#	define GRAM_K5_EXE "globus-k5"
#endif
#ifndef GLOBUS_LIBEXECDIR
#  define GLOBUS_LIBEXECDIR "libexec"
#endif
#ifndef GLOBUS_GATEKEEPER_HOME
#	define GLOBUS_GATEKEEPER_HOME "/etc"
#endif
#ifndef LOGFILE
#define LOGFILE ""
#endif

#ifndef PATH_MAX
#define PATH_MAX MAXPATHLEN
#endif

static char     tmpbuf[1024];
#define notice2(i,a,b) {sprintf(tmpbuf, a,b); notice(i,tmpbuf);}
#define notice3(i,a,b,c) {sprintf(tmpbuf, a,b,c); notice(i,tmpbuf);}
#define notice4(i,a,b,c,d) {sprintf(tmpbuf, a,b,c,d); notice(i,tmpbuf);}
#define failure2(a,b) {sprintf(tmpbuf, a,b); failure(tmpbuf);}
#define failure3(a,b,c) {sprintf(tmpbuf, a,b,c); failure(tmpbuf);}
#define failure4(a,b,c,d) {sprintf(tmpbuf, a,b,c,d); failure(tmpbuf);}

#if ! defined(TARGET_ARCH_LINUX) & ! defined(TARGET_ARCH_FREEBSD)
extern char *   sys_errlist[];
#endif

extern int      errno;

static int      connection_fd;

static FILE *   usrlog_fp;
static char *   logfile = LOGFILE;
static FILE *   test_fp;
static char     test_dat_file[1024];
static int      gatekeeper_test;
static int      gatekeeper_uid;
static int      daemon_port;
static int      logging_syslog;
static int      logging_usrlog;
static int      debug;
static int      foreground;
static int      krb5flag;
static int      run_from_inetd;
static char *   gatekeeperhome = NULL;
static char *   jm_conf_path = NULL;
static char *   libexecdir = GLOBUS_LIBEXECDIR;
static char *   job_manager_exe = NULL;
static char *   globusmap = "globusmap";
static char *   globuskmap = "globuskmap";
static char *   globuspwd = NULL;
static char *   globuscertdir = "cert";
static char *   globuskeydir = "key";
static char *   x509_cert_dir = NULL;
static char *   x509_cert_file = NULL;
static char *   x509_user_proxy = NULL;
static char *   x509_user_cert = NULL;
static char *   x509_user_key = NULL;
static char **  jmargp;
static int      jmargc;<commit_msg>Added the static char * globusnologin to identify the name of the globus nologin filename<commit_after>/******************************************************************************
gram_gatekeeper.c
 
Description:
    Resource Managemant gatekeeper.
 
CVS Information:
 
    $Source$
    $Date$
    $Revision$
    $Author$

 This source file has been modified by <NAME> (<EMAIL>)
 with extensions for UNICOS.
 September 1998
 
******************************************************************************/

/******************************************************************************
                             Include header files
******************************************************************************/
#if defined(_AIX32) && !defined(_ALL_SOURCE)
#define _ALL_SOURCE
#endif
#include "globus_config.h"
#include "globus_i_gram_version.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <fcntl.h>
#include <pwd.h>
#include <sys/param.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/socket.h>
#include <syslog.h>
#include <netdb.h>
#include <netinet/in.h>
#if defined (HAVE_NETINET_TCP_H)
#   include <netinet/tcp.h>
#endif
#include <arpa/inet.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/signal.h>
#include <sys/wait.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif

#ifdef GSS_AUTHENTICATION
#include "globus_gss_assist.h"
#include <gssapi.h>
#endif

#if defined(TARGET_ARCH_SOLARIS)
#include <termios.h>
#endif

#if defined(TARGET_ARCH_AIX)
#define netlen_t size_t
#else
#define netlen_t int
#endif

#include <strings.h>

#include <arpa/inet.h> /* for inet_ntoa() */

#ifdef BSD
#include <strings.h>
#endif

#ifdef SYSV
#include <string.h>
#endif

#if defined(TARGET_ARCH_CRAYT3E)
#include "unicos.h"
#endif

#if defined(HAVE_PROJ_H) && defined(TARGET_ARCH_IRIX)
#include <proj.h>
#endif

#if !defined(MAXPATHLEN) 
#   define MAXPATHLEN PATH_MAX
#endif

/******************************************************************************
                               Type definitions
******************************************************************************/

/******************************************************************************
                          Module specific prototypes
******************************************************************************/
static void 
doit();
static int 
logging_startup(void);
static int
logging_phase2(void);
static void 
failure(char *s);
static void 
notice(int, char *s);
static int 
net_accept(int socket);
static void 
net_setup_listener(int backlog, int *port, int *socket);
static void 
error_check(int val, char *string);
static char 
*timestamp(void);
static int
tokenize(char * command, char ** args, int * n);

static char *
genfilename(char * prefix, char * path, char * sufix);

/*
 * GSSAPI - credential handle for this process
 */

static gss_cred_id_t credential_handle = GSS_C_NO_CREDENTIAL;

/******************************************************************************
                       Define module specific variables
******************************************************************************/
#define MAXARGS 256
#define DEFAULT_PORT 754
#define MAX_MESSAGE_LENGTH 100000
#ifndef GRAM_K5_EXE
#	define GRAM_K5_EXE "globus-k5"
#endif
#ifndef GLOBUS_LIBEXECDIR
#  define GLOBUS_LIBEXECDIR "libexec"
#endif
#ifndef GLOBUS_GATEKEEPER_HOME
#	define GLOBUS_GATEKEEPER_HOME "/etc"
#endif
#ifndef LOGFILE
#define LOGFILE ""
#endif

#ifndef PATH_MAX
#define PATH_MAX MAXPATHLEN
#endif

static char     tmpbuf[1024];
#define notice2(i,a,b) {sprintf(tmpbuf, a,b); notice(i,tmpbuf);}
#define notice3(i,a,b,c) {sprintf(tmpbuf, a,b,c); notice(i,tmpbuf);}
#define notice4(i,a,b,c,d) {sprintf(tmpbuf, a,b,c,d); notice(i,tmpbuf);}
#define failure2(a,b) {sprintf(tmpbuf, a,b); failure(tmpbuf);}
#define failure3(a,b,c) {sprintf(tmpbuf, a,b,c); failure(tmpbuf);}
#define failure4(a,b,c,d) {sprintf(tmpbuf, a,b,c,d); failure(tmpbuf);}

#if ! defined(TARGET_ARCH_LINUX) & ! defined(TARGET_ARCH_FREEBSD)
extern char *   sys_errlist[];
#endif

extern int      errno;

static int      connection_fd;

static FILE *   usrlog_fp;
static char *   logfile = LOGFILE;
static FILE *   test_fp;
static char     test_dat_file[1024];
static int      gatekeeper_test;
static int      gatekeeper_uid;
static int      daemon_port;
static int      logging_syslog;
static int      logging_usrlog;
static int      debug;
static int      foreground;
static int      krb5flag;
static int      run_from_inetd;
static char *   gatekeeperhome = NULL;
static char *   jm_conf_path = NULL;
static char *   libexecdir = GLOBUS_LIBEXECDIR;
static char *   job_manager_exe = NULL;
static char *   globusmap = "globusmap";
static char *   globuskmap = "globuskmap";
static char *   globuspwd = NULL;
static char *   globuscertdir = "cert";
static char *   globuskeydir = "key";
static char *   globusnologin ="globus-nologin";
static char *   x509_cert_dir = NULL;
static char *   x509_cert_file = NULL;
static char *   x509_user_proxy = NULL;
static char *   x509_user_cert = NULL;
static char *   x509_user_key = NULL;
static char **  jmargp;
static int      jmargc;
{'fraction_non_alphanumeric': 0.2513194511083389, 'fraction_numerical': 0.010171768544285578, 'mean_word_length': 5.192513368983957, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7304153', 'n_tokens_mistral': 3515, 'n_tokens_neox': 3361, 'n_words': 836}