⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ckufio.c

📁 C-Kermit源码。是使用串口/Modem和网络通讯的程序
💻 C
📖 第 1 页 / 共 5 页
字号:
_PROTOTYP( VOID ignorsigs, (void) );_PROTOTYP( VOID restorsigs, (void) );/*  Change argument to "(const char *)" if this causes trouble.  Or... if it causes trouble, then maybe it was already declared  in a header file after all, so you can remove this prototype.*/#ifndef NDGPWNAM /* If not defined No Declare getpwnam... */#ifndef _POSIX_SOURCE#ifndef NEXT#ifndef SVR4/* POSIX <pwd.h> already gave prototypes for these. */#ifdef IRIX40_PROTOTYP( struct passwd * getpwnam, (const char *) );#else#ifdef IRIX51_PROTOTYP( struct passwd * getpwnam, (const char *) );#else#ifdef M_UNIX_PROTOTYP( struct passwd * getpwnam, (const char *) );#else#ifdef HPUX9_PROTOTYP( struct passwd * getpwnam, (const char *) );#else#ifdef HPUX10_PROTOTYP( struct passwd * getpwnam, (const char *) );#else#ifdef DCGPWNAM_PROTOTYP( struct passwd * getpwnam, (const char *) );#else_PROTOTYP( struct passwd * getpwnam, (char *) );#endif /* DCGPWNAM */#endif /* HPUX10 */#endif /* HPUX9 */#endif /* M_UNIX */#endif /* IRIX51 */#endif /* IRIX40 */#ifndef SUNOS4#ifndef HPUX9#ifndef HPUX10#ifndef _SCO_DS_PROTOTYP( struct passwd * getpwuid, (PWID_T) );#endif /* _SCO_DS */#endif /* HPUX10 */#endif /* HPUX9 */#endif /* SUNOS4 */_PROTOTYP( struct passwd * getpwent, (void) );#endif /* SVR4 */#endif /* NEXT */#endif /* _POSIX_SOURCE */#endif /* NDGPWNAM */#ifdef CK_SHADOW                        /* Shadow Passwords... */#include <shadow.h>#endif /* CK_SHADOW */#ifdef CK_PAM                           /* PAM... */#include <security/pam_appl.h>#ifndef PAM_SERVICE_TYPE                /* Defines which PAM service we are */#define PAM_SERVICE_TYPE "kermit"#endif /* PAM_SERVICE_TYPE */int#ifdef CK_ANSICpam_cb(int num_msg,       const struct pam_message **msg,       struct pam_response **resp,       void *appdata_ptr       )#else /* CK_ANSIC */pam_cb(num_msg, msg, resp, appdata_ptr)    int num_msg;    const struct pam_message **msg;    struct pam_response **resp;    void *appdata_ptr;#endif /* CK_ANSIC */{    int i;    debug(F111,"pam_cb","num_msg",num_msg);    for (i = 0; i < num_msg; i++) {        char message[PAM_MAX_MSG_SIZE];        /* Issue prompt and get response */        debug(F111,"pam_cb","Message",i);        debug(F111,"pam_cb",msg[i]->msg,msg[i]->msg_style);        if (msg[i]->msg_style == PAM_ERROR_MSG) {            debug(F111,"pam_cb","PAM ERROR",0);            fprintf(stdout,"%s\n", msg[i]->msg);            return(0);        } else if (msg[i]->msg_style == PAM_TEXT_INFO) {            debug(F111,"pam_cb","PAM TEXT INFO",0);            fprintf(stdout,"%s\n", msg[i]->msg);            return(0);        } else if (msg[i]->msg_style == PAM_PROMPT_ECHO_OFF) {            debug(F111,"pam_cb","Reading response, no echo",0);            readpass(msg[i]->msg,message,PAM_MAX_MSG_SIZE);        } else if (msg[i]->msg_style == PAM_PROMPT_ECHO_ON) {            debug(F111,"pam_cb","Reading response, with echo",0);            readtext(msg[i]->msg,message,PAM_MAX_MSG_SIZE);        } else {            debug(F111,"pam_cb","unknown style",0);            return(0);        }        /* Allocate space for this message's response structure */        resp[i] = (struct pam_response *) malloc(sizeof (struct pam_response));        if (!resp[i]) {            int j;            debug(F110,"pam_cb","malloc failure",0);            for (j = 0; j < i; j++) {                free(resp[j]->resp);                free(resp[j]);            }            return(0);        }        /* Allocate a buffer for the response */        resp[i]->resp = (char *) malloc((int)strlen(message) + 1);        if (!resp[i]->resp) {            int j;            debug(F110,"pam_cb","malloc failure",0);            for (j = 0; j < i; j++) {                free(resp[j]->resp);                free(resp[j]);            }            free(resp[i]);            return(0);        }        /* Return the results back to PAM */        strcpy(resp[i]->resp, message);        resp[i]->resp_retcode = 0;    }    debug(F110,"pam_cb","Exiting",0);    return(0);}#endif /* CK_PAM *//* Define macros for getting file type */#ifdef OXOS/*  Olivetti X/OS 2.3 has S_ISREG and S_ISDIR defined  incorrectly, so we force their redefinition.*/#undef S_ISREG#undef S_ISDIR#endif /* OXOS */#ifdef UTSV                             /* Same deal for Amdahl UTSV */#undef S_ISREG#undef S_ISDIR#endif /* UTSV */#ifdef UNISYS52                         /* And for UNISYS UTS V 5.2 */#undef S_ISREG#undef S_ISDIR#endif /* UNISYS52 */#ifdef ICLSVR3                          /* And for old ICL versions */#undef S_ISREG#undef S_ISDIR#endif /* ICLSVR3 */#ifdef ISDIRBUG                         /* Also allow this from command line */#ifdef S_ISREG#undef S_ISREG#endif /* S_ISREG */#ifdef S_ISDIR#undef S_ISDIR#endif /*  S_ISDIR */#endif /* ISDIRBUG */#ifndef _IFMT#ifdef S_IFMT#define _IFMT S_IFMT#else#define _IFMT 0170000#endif /* S_IFMT */#endif /* _IFMT */#ifndef S_ISREG#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)#endif /* S_ISREG */#ifndef S_ISDIR#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)#endif /* S_ISDIR *//* The following mainly for NeXTSTEP... */#ifndef S_IWUSR#define S_IWUSR 0000200#endif /* S_IWUSR */#ifndef S_IRGRP#define S_IRGRP 0000040#endif /* S_IRGRP */#ifndef S_IWGRP#define S_IWGRP 0000020#endif /* S_IWGRP */#ifndef S_IXGRP#define S_IXGRP 0000010#endif /* S_IXGRP */#ifndef S_IROTH#define S_IROTH 0000004#endif /* S_IROTH */#ifndef S_IWOTH#define S_IWOTH 0000002#endif /* S_IWOTH */#ifndef S_IXOTH#define S_IXOTH 0000001#endif /* S_IXOTH *//*  Define maximum length for a file name if not already defined.  NOTE: This applies to a path segment (directory or file name),  not the entire path string, which can be CKMAXPATH bytes long.*/#ifdef QNX#ifdef _MAX_FNAME#define MAXNAMLEN _MAX_FNAME#else#define MAXNAMLEN 48#endif /* _MAX_FNAME */#else#ifndef MAXNAMLEN#ifdef sun#define MAXNAMLEN 255#else#ifdef FILENAME_MAX#define MAXNAMLEN FILENAME_MAX#else#ifdef NAME_MAX#define MAXNAMLEN NAME_MAX#else#ifdef _POSIX_NAME_MAX#define MAXNAMLEN _POSIX_NAME_MAX#else#ifdef _D_NAME_MAX#define MAXNAMLEN _D_NAME_MAX#else#ifdef DIRSIZ#define MAXNAMLEN DIRSIZ#else#define MAXNAMLEN 14#endif /* DIRSIZ */#endif /* _D_NAME_MAX */#endif /* _POSIX_NAME_MAX */#endif /* NAME_MAX */#endif /* FILENAME_MAX */#endif /* sun */#endif /* MAXNAMLEN */#endif /* QNX *//* Longest pathname ... *//*  Beware: MAXPATHLEN is one of UNIX's dirty little secrets.  Where is it  defined?  Who knows...  <param.h>, <mod.h>, <unistd.h>, <limits.h>, ...  There is not necessarily even a definition for it anywhere, or it might have  another name.  If you get it wrong, bad things happen with getcwd() and/or  getwd().  If you allocate a buffer that is too short, getwd() might write  over memory and getcwd() will fail with ERANGE.  The definitions of these  functions (e.g. in SVID or POSIX.1) do not tell you how to determine the  maximum path length in order to allocate a buffer that is the right size.*/#ifdef BSD44#include <sys/param.h>                  /* For MAXPATHLEN */#endif /* BSD44 */#ifdef COHERENT#include <sys/param.h>  /* for MAXPATHLEN, needed for -DDIRENT */#endif /* COHERENT */#ifdef MAXPATHLEN#ifdef MAXPATH#undef MAXPATH#endif /* MAXPATH */#define MAXPATH MAXPATHLEN#else#ifdef PATH_MAX#define MAXPATH PATH_MAX#else#ifdef _POSIX_PATH_MAX#define MAXPATH _POSIX_PATH_MAX#else#ifdef BSD42#define MAXPATH 1024#else#ifdef SVR4#define MAXPATH 1024#else#define MAXPATH 255#endif /* SVR4 */#endif /* BSD42 */#endif /* _POSIX_PATH_MAX */#endif /* PATH_MAX */#endif /* MAXPATHLEN *//* Maximum number of filenames for wildcard expansion */#ifndef MAXWLD                          /* (see ckcdeb.h) */#ifdef CK_SMALL#define MAXWLD 50#else#ifdef BIGBUFOK#define MAXWLD 102400#else#define MAXWLD 4096#endif /* BIGBUFOK */#endif /* CK_SMALL */#endif /* MAXWLD */#ifdef DCLFDOPEN/* fdopen() needs declaring because it's not declared in <stdio.h> */_PROTOTYP( FILE * fdopen, (int, char *) );#endif /* DCLFDOPEN */#ifdef DCLPOPEN/* popen() needs declaring because it's not declared in <stdio.h> */_PROTOTYP( FILE * popen, (char *, char *) );#endif /* DCLPOPEN */extern int nopush;/* More internal function prototypes *//* * The path structure is used to represent the name to match. * Each slash-separated segment of the name is kept in one * such structure, and they are linked together, to make * traversing the name easier. */struct path {    char npart[MAXNAMLEN+4];            /* name part of path segment */    struct path *fwd;                   /* forward ptr */};#ifndef NOPUSH_PROTOTYP( int shxpand, (char *, char *[], int ) );#endif /* NOPUSH */_PROTOTYP( static int fgen, (char *, char *[], int ) );_PROTOTYP( static VOID traverse, (struct path *, char *, char *) );_PROTOTYP( static VOID addresult, (char *, int) );#ifdef COMMENT/* Replaced by ckmatch() */_PROTOTYP( static int match, (char *, char *) );#endif /* COMMENT */_PROTOTYP( char * whoami, (void) );_PROTOTYP( UID_T real_uid, (void) );_PROTOTYP( static struct path *splitpath, (char *p) );_PROTOTYP( char * zdtstr, (time_t) );_PROTOTYP( time_t zstrdt, (char *, int) );/* Some systems define these symbols in include files, others don't... */#ifndef R_OK#define R_OK 4                          /* For access */#endif /* R_OK */#ifndef W_OK#define W_OK 2#endif /* W_OK */#ifndef O_RDONLY#define O_RDONLY 000#endif /* O_RDONLY *//* syslog and wtmp items for Internet Kermit Service */extern char * clienthost;               /* From ckcmai.c. */static char fullname[CKMAXPATH+1];static char tmp2[CKMAXPATH+1];extern int ckxlogging;#ifdef CKXPRINTF                        /* Our printf macro conflicts with */#undef printf                           /* use of "printf" in syslog.h */#endif /* CKXPRINTF */#ifdef CKSYSLOG#include <syslog.h>#endif /* CKSYSLOG */#ifdef CKXPRINTF#define printf ckxprintf#endif /* CKXPRINTF */int ckxanon = 1;                        /* Anonymous login ok */int ckxperms = 0040;                    /* Anonymous file permissions */int ckxpriv = 1;			/* Priv'd login ok */#ifndef XFERFILE#define XFERFILE "/var/log/iksd.log"#endif /* XFERFILE *//* wtmp logging for IKSD... */#ifndef CKWTMP                          /* wtmp logging not selected */int ckxwtmp = 0;                        /* Know this at runtime */#else                                   /* wtmp file details */int ckxwtmp = 1;#ifdef UTMPBUG                          /* Unfortunately... *//*  Some versions of Linux have a <utmp.h> file that contains  "enum utlogin { local, telnet, rlogin, screen, ... };"  This clobbers  any program that uses any of these words as variable names, function  names, macro names, etc.  (Other versions of Linux have this declaration  within #if 0 ... #endif.)  There is nothing we can do about this other  than to not include the stupid file.  But we need stuff from it, so...*/#include <features.h>#include <sys/types.h>#define UT_LINESIZE     32#define UT_NAMESIZE     32#define UT_HOSTSIZE     256struct timeval {  time_t tv_sec;  time_t tv_usec;};struct exit_status {  short int e_termination;      /* Process termination status.  */  short int e_exit;             /* Process exit status.  */};struct utmp {  short int ut_type;                    /* Type of login */  pid_t ut_pid;                         /* Pid of login process */  char ut_line[UT_LINESIZE];            /* NUL-terminated devicename of tty */  char ut_id[4];                        /* Inittab id */  char ut_user[UT_NAMESIZE];            /* Username (not NUL terminated) */  char ut_host[UT_HOSTSIZE];            /* Hostname for remote login */  struct exit_status ut_exit;           /* Exit status */  long ut_session;                      /* Session ID, used for windowing */  struct timeval ut_tv;                 /* Time entry was made */  int32_t ut_addr_v6[4];                /* Internet address of remote host */  char pad[20];                         /* Reserved */};#define ut_time ut_tv.tv_sec    /* Why should Linux be like anything else? */#define ut_name ut_user         /* ... */extern voidlogwtmp __P ((__const char *__ut_line, __const char *__ut_name,                          __const char *__ut_host));#else  /* Not UTMPBUG */#ifndef HAVEUTMPX                       /* Who has <utmpx.h> */#ifdef SOLARIS#define HAVEUTMPX

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -