Ejemplo n.º 1
0
static int match_version(pool *p, const char *pattern_str, char **error) {
#ifdef PR_USE_REGEX
  pr_regex_t *pre;
  int res;

  pre = pr_regexp_alloc(&ifversion_module);

  res = pr_regexp_compile(pre, pattern_str, REG_EXTENDED|REG_NOSUB|REG_ICASE);
  if (res != 0) {
    char errstr[256];

    memset(errstr, '\0', sizeof(errstr));
    pr_regexp_error(res, pre, errstr, sizeof(errstr)-1);

    pr_regexp_free(NULL, pre);
    *error = pstrcat(p, "unable to compile pattern '", pattern_str, "': ",
      errstr, NULL);

    return 0;
  }

  res = pr_regexp_exec(pre, pr_version_get_str(), 0, NULL, 0, 0, 0);
  if (res != 0) {
    *error = pstrcat(p, "server version '", pr_version_get_str(),
      "' failed to match pattern '", pattern_str, "'", NULL);
  }

  pr_regexp_free(NULL, pre);
  return (res == 0 ? 1 : 0);

#else
  *error = pstrdup(p, "system does not support POSIX regular expressions");
  return 0;
#endif /* regex support */
}
Ejemplo n.º 2
0
/* usage: ModulePath path */
MODRET set_modulepath(cmd_rec *cmd) {
  int res;
  struct stat st;

  CHECK_ARGS(cmd, 1);
  CHECK_CONF(cmd, CONF_ROOT);

  if (pr_fs_valid_path(cmd->argv[1]) < 0)
    CONF_ERROR(cmd, "must be an absolute path");

  /* Make sure that the configured path is not world-writeable. */
  res = pr_fsio_stat(cmd->argv[1], &st);
  if (res < 0)
    CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, "error checking '",
      cmd->argv[1], "': ", strerror(errno), NULL)); 

  if (!S_ISDIR(st.st_mode))
    CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, cmd->argv[1], " is not a directory",
      NULL));

  if (st.st_mode & S_IWOTH)
    CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, cmd->argv[1], " is world-writable",
      NULL));

  if (lt_dlsetsearchpath(cmd->argv[1]) < 0)
    CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, "error setting module path: ",
      lt_dlerror(), NULL));

  dso_module_path = pstrdup(dso_pool, cmd->argv[1]);
  return PR_HANDLED(cmd);
}
Ejemplo n.º 3
0
static char *myfgets(char *s, int n, FILE *stream)
{
    char *LString1;
    char *LString2;
    char *temp;
    pstring String;
    pstring NewString;
    int i;

    fgets(s,n,stream);
    while ((LString1 = strchr(s,'%')) != NULL) {
        if (!(LString2 = strchr(LString1+1,'%'))) break;
        *LString2 = '\0';
        pstrcpy(String,LString1+1);
        i = 0;
        while(*sbuffer[i]!='\0') {
            if (strncmp(sbuffer[i],String,strlen(String))==0)
            {
                pstrcpy(String,sbuffer[i]);
                if ((temp = strchr(String,'=')) != NULL) ++temp;
                pstrcpy(String,temp);
                break;
            }
            i++;
        }
        *LString1 = '\0';
        pstrcpy(NewString,s);
        pstrcat(NewString,String);
        pstrcat(NewString,LString2+1);
        pstrcpy(s, NewString);
    }
    return(s);
}
Ejemplo n.º 4
0
static void do_tar(file_info *finfo)
{
	pstring rname;

	if (strequal(finfo->name,"..") || strequal(finfo->name,"."))
		return;

	/* Is it on the exclude list ? */
	if (!tar_excl && clipn) {
		pstring exclaim;

		DEBUG(5, ("Excl: strlen(cur_dir) = %d\n", (int)strlen(cur_dir)));

		pstrcpy(exclaim, cur_dir);
		*(exclaim+strlen(exclaim)-1)='\0';

		pstrcat(exclaim, "\\");
		pstrcat(exclaim, finfo->name);

		DEBUG(5, ("...tar_re_search: %d\n", tar_re_search));

		if ((!tar_re_search && clipfind(cliplist, clipn, exclaim)) ||
#ifdef HAVE_REGEX_H
				(tar_re_search && !regexec(preg, exclaim, 0, NULL, 0))) {
#else
				(tar_re_search && mask_match_list(exclaim, cliplist, clipn, True))) {
#endif
			DEBUG(3,("Skipping file %s\n", exclaim));
			return;
		}
	}
Ejemplo n.º 5
0
/* If the path has the home directory in it, replace it with a tilde. */
int tilde_expand(char *buf, int buf_size, const char *path1)
{
    char path[MAX_FILENAME_SIZE];
    char *homedir;
    int ret = 0;
    if (!is_abs_path(path1)) {
        if (*path1 == '~') {
            if (path1[1] == '\0' || path1[1] == '/') {
                homedir = getenv("HOME");
                if (homedir) {
                    pstrcpy(path, sizeof(path), homedir);
#ifdef CONFIG_WIN32
                    path_win_to_unix(path);
#endif
                    remove_slash(path);
                    pstrcat(path, sizeof(path), path1 + 1);
                    path1 = path;
                }
            } else {
                /* CG: should get info from getpwnam */
                pstrcpy(path, sizeof(path), "/home/");
                pstrcat(path, sizeof(path), path1 + 1);
                path1 = path;
            }
            ret = 1;
        }
    }
    pstrcpy(buf, buf_size, path1);
    return ret;
}
Ejemplo n.º 6
0
static const char *describe_eacces_file(pool *p, const char *path, int flags) {
  if (flags & EXPLAIN_PATH_FL_WANT_SEARCH) {
    return pstrcat(p, "file '", path, "' is not searchable by the user", NULL);
  }

  return pstrcat(p, "directory containing '", path,
    "' is not writable by the user", NULL);
}
Ejemplo n.º 7
0
/****************************************************************************
Build the print command in the supplied buffer. This means getting the
print command for the service and inserting the printer name and the
print file name. Return NULL on error, else the passed buffer pointer.
****************************************************************************/
static char *build_print_command(int cnum, char *command, char *syscmd, char *filename1)
{
  int snum = SNUM(cnum);
  char *tstr;
  pstring filename;
  
  /* get the print command for the service. */
  tstr = command;
  if (!syscmd || !tstr) {
    DEBUG(0,("No print command for service `%s'\n", SERVICE(snum)));
    return (NULL);
  }

  /* copy the command into the buffer for extensive meddling. */
  StrnCpy(syscmd, tstr, sizeof(pstring) - 1);
  
  /* look for "%s" in the string. If there is no %s, we cannot print. */   
  if (!strstr(syscmd, "%s") && !strstr(syscmd, "%f")) {
    DEBUG(2,("WARNING! No placeholder for the filename in the print command for service %s!\n", SERVICE(snum)));
  }
  
  if (strstr(syscmd,"%s")) {
    int iOffset = PTR_DIFF(strstr(syscmd, "%s"),syscmd);
    
    /* construct the full path for the filename, shouldn't be necessary unless
       the subshell causes a "cd" to be executed.
       Only use the full path if there isn't a / preceding the %s */
    if (iOffset==0 || syscmd[iOffset-1] != '/') {
      StrnCpy(filename,Connections[cnum].connectpath,sizeof(filename)-1);
      trim_string(filename,"","/");
      pstrcat(filename,"/");
      pstrcat(filename,filename1);
    }
    else
      pstrcpy(filename,filename1);
    
    string_sub(syscmd, "%s", filename);
  }
  
  string_sub(syscmd, "%f", filename1);
  
  /* Does the service have a printername? If not, make a fake and empty    */
  /* printer name. That way a %p is treated sanely if no printer */
  /* name was specified to replace it. This eventuality is logged.         */
  tstr = PRINTERNAME(snum);
  if (tstr == NULL || tstr[0] == '\0') {
    DEBUG(3,( "No printer name - using %s.\n", SERVICE(snum)));
    tstr = SERVICE(snum);
  }
  
  string_sub(syscmd, "%p", tstr);
  
  standard_sub(cnum,syscmd);
  
  return (syscmd);
}
Ejemplo n.º 8
0
/****************************************************************************
mount smbfs
****************************************************************************/
static void cmd_mount(char *inbuf,char *outbuf)
{
	pstring mpoint;
	pstring share_name;
	pstring mount_command;
	fstring buf;
	int retval;
	char mount_point[MAXPATHLEN+1];

	if (!next_token(NULL, mpoint, NULL))
	{
		DEBUG(0,("You must supply a mount point\n"));
		return;
	}

	memset(mount_point, 0, sizeof(mount_point));

	if (realpath(mpoint, mount_point) == NULL)
	{
		DEBUG(0, ("Could not resolve mount point\n"));
		return;
	}

	/*
	 * Build the service name to report on the Unix side,
	 * converting '\' to '/' and ' ' to '_'.
	 */
	pstrcpy(share_name, service);  
	string_replace(share_name, '\\', '/');
	string_replace(share_name, ' ', '_');

	slprintf(mount_command, sizeof(mount_command)-1,"smbmnt %s -s %s", mount_point, share_name);

	while(next_token(NULL, buf, NULL))
	{
		pstrcat(mount_command, " ");
		pstrcat(mount_command, buf);
	}

	DEBUG(3, ("mount command: %s\n", mount_command));

	/*
	 * Create the background process before trying the mount.
	 * (We delay closing files to allow diagnostic messages.)
	 */
	daemonize();

	/* The parent has exited here, the child handles the connection: */
	if ((retval = system(mount_command)) != 0)
	{
		DEBUG(0,("mount failed\n"));
		exit(1);
	}
	send_fs_socket(mount_point, inbuf, outbuf);
}	
Ejemplo n.º 9
0
static int set_schema_version(pool *p, const char *schema_name,
    unsigned int schema_version) {
  int res, xerrno = 0;
  const char *stmt, *errstr = NULL;
  array_header *results;

  /* CREATE TABLE $schema_name.schema_version (
   *   schema TEXT NOT NULL PRIMARY KEY,
   *   version INTEGER NOT NULL
   * );
   */
  stmt = pstrcat(p, "CREATE TABLE IF NOT EXISTS ", schema_name, ".schema_version (schema TEXT NOT NULL PRIMARY KEY, version INTEGER NOT NULL);", NULL);
  res = proxy_db_exec_stmt(p, stmt, &errstr);
  if (res < 0) {
    (void) pr_log_debug(DEBUG3, MOD_PROXY_VERSION
      ": error executing statement '%s': %s", stmt, errstr);
    errno = EPERM;
    return -1;
  }

  stmt = pstrcat(p, "INSERT INTO ", schema_name, ".schema_version (schema, version) VALUES (?, ?);", NULL);
  res = proxy_db_prepare_stmt(p, stmt);
  if (res < 0) {
    xerrno = errno;

    (void) pr_log_debug(DEBUG3, MOD_PROXY_VERSION
      ": error preparing statement '%s': %s", stmt, strerror(xerrno));
    errno = xerrno;
    return -1;
  }

  res = proxy_db_bind_stmt(p, stmt, 1, PROXY_DB_BIND_TYPE_TEXT,
    (void *) schema_name);
  if (res < 0) {
    return -1;
  }

  res = proxy_db_bind_stmt(p, stmt, 2, PROXY_DB_BIND_TYPE_INT,
    (void *) &schema_version);
  if (res < 0) {
    return -1;
  }

  results = proxy_db_exec_prepared_stmt(p, stmt, &errstr);
  if (results == NULL) {
    (void) pr_log_debug(DEBUG3, MOD_PROXY_VERSION
      ": error executing statement '%s': %s", stmt,
      errstr ? errstr : strerror(errno));
    errno = EPERM;
    return -1;
  }

  return 0;
}
Ejemplo n.º 10
0
static int compare_version(pool *p, char *version_str, char **error) {
  char *server_version_str;
  unsigned int version_status = 0, server_version_status = 0;
  unsigned int version[3] = { 0, 0, 0 }, server_version[3] = { 0, 0, 0 };
  int res;

  res = parse_version(version_str, version, &version_status);
  if (res < 0) {
    *error = pstrcat(p, "badly formatted configured version '", version_str,
      "'", NULL);
    return -1;
  }

  server_version_str = pstrdup(p, pr_version_get_str());
  res = parse_version(server_version_str, server_version,
    &server_version_status);
  if (res < 0) {
    *error = pstrcat(p, "badly formatted server version '", server_version_str,
      "'", NULL);
    return -1;
  }

  *error = NULL;

  if (server_version[0] > version[0]) {
    return 1;

  } else if (server_version[0] < version[0]) {
    return -1;

  } else if (server_version[1] > version[1]) {
    return 1;

  } else if (server_version[1] < version[1]) {
    return -1;

  } else if (server_version[2] > version[2]) {
    return 1;

  } else if (server_version[2] < version[2]) {
    return -1;

  } else if (server_version_status > version_status) {
    return 1;

  } else if (server_version_status < version_status) {
    return -1;
  }

  /* Appear to be the same versions. */
  return 0;
}
Ejemplo n.º 11
0
static char *reg_test(char *pattern, char *file)
{
	static fstring ret;
	pstring rpattern;
	regex_t preg;

	pattern = 1+strrchr(pattern,'\\');
	file = 1+strrchr(file,'\\');

	fstrcpy(ret,"---");

	if (strcmp(file,"..") == 0) file = ".";
	if (strcmp(pattern,".") == 0) return ret;

	if (strcmp(pattern,"") == 0) {
		ret[2] = '+';
		return ret;
	}

	pstrcpy(rpattern,"^");
	pstrcat(rpattern, pattern);

	all_string_sub(rpattern,".", "[.]", 0);
	all_string_sub(rpattern,"?", ".{1}", 0);
	all_string_sub(rpattern,"*", ".*", 0);
	all_string_sub(rpattern+strlen(rpattern)-1,">", "([^.]?|[.]?$)", 0);
	all_string_sub(rpattern,">", "[^.]?", 0);

	all_string_sub(rpattern,"<[.]", ".*[.]", 0);
	all_string_sub(rpattern,"<\"", "(.*[.]|.*$)", 0);
	all_string_sub(rpattern,"<", "([^.]*|[^.]*[.]|[.][^.]*|[.].*[.])", 0);
	if (strlen(pattern)>1) {
		all_string_sub(rpattern+strlen(rpattern)-1,"\"", "[.]?", 0);
	}
	all_string_sub(rpattern,"\"", "([.]|$)", 0);
	pstrcat(rpattern,"$");

	/* printf("pattern=[%s] rpattern=[%s]\n", pattern, rpattern); */

	regcomp(&preg, rpattern, REG_ICASE|REG_NOSUB|REG_EXTENDED);
	if (regexec(&preg, ".", 0, NULL, 0) == 0) {
		ret[0] = '+';
		ret[1] = '+';
	}
	if (regexec(&preg, file, 0, NULL, 0) == 0) {
		ret[2] = '+';
	}
	regfree(&preg);

	return ret;
}
Ejemplo n.º 12
0
Archivo: ppm.c Proyecto: foogywoo/drone
rwpipe *rwpipe_open( int argc, char *argv[] )
{
    rwpipe *this = av_mallocz( sizeof( rwpipe ) );

    if ( this != NULL )
    {
        int input[ 2 ];
        int output[ 2 ];

        pipe( input );
        pipe( output );

        this->pid = fork();

        if ( this->pid == 0 )
        {
#define COMMAND_SIZE 10240
            char *command = av_mallocz( COMMAND_SIZE );
            int i;

            strcpy( command, "" );
            for ( i = 0; i < argc; i ++ )
            {
                pstrcat( command, COMMAND_SIZE, argv[ i ] );
                pstrcat( command, COMMAND_SIZE, " " );
            }

            dup2( output[ 0 ], STDIN_FILENO );
            dup2( input[ 1 ], STDOUT_FILENO );

            close( input[ 0 ] );
            close( input[ 1 ] );
            close( output[ 0 ] );
            close( output[ 1 ] );

            execl("/bin/sh", "sh", "-c", command, NULL );
            exit( 255 );
        }
        else
        {
            close( input[ 1 ] );
            close( output[ 0 ] );

            this->reader = fdopen( input[ 0 ], "r" );
            this->writer = fdopen( output[ 1 ], "w" );
        }
    }

    return this;
}
Ejemplo n.º 13
0
/*
   Lockup an entry in a file
   Return all the lines between the entry and the next one or the end of file
   An entry is something between braces.
*/
static void lookup_entry(FILE *fichier,char *chaine)
{
    int found=0,pointeur=0,i=0;
    char *temp,*temp2;

    temp=(char *)malloc(sizeof(pstring));
    temp2=(char *)malloc(sizeof(pstring));

    if(temp == NULL || temp2 == NULL) {
        fprintf(stderr,"lookup_entry: malloc fail !\n");
        exit(1);
    }

    *buffer[0]='\0';

    pstrcpy(temp2,"[");
    pstrcat(temp2,chaine);
    pstrcat(temp2,"]");

    rewind(fichier);
#ifdef DEBUGIT
    fprintf(stderr,"\tLooking for %s\n",chaine);
#endif

    while (!feof(fichier) && found==0) {
        *temp='\0';
        myfgets(temp,255,fichier);
        if (strncmp(temp,temp2,strlen(temp2))==0) found=1;
    }


    while (!feof(fichier) && found==1) {
        *temp='\0';
        myfgets(temp,255,fichier);
        if (*temp=='[') {
            found=2;
            *buffer[pointeur]='\0';
        }
        else {
            pstrcpy(buffer[pointeur],temp);
            i=strlen(buffer[pointeur])-1;
            while (buffer[pointeur][i]=='\r' || buffer[pointeur][i]=='\n')
                buffer[pointeur][i--]='\0';
            pointeur++;
        }
    }
#ifdef DEBUGIT
    fprintf(stderr,"\t\tFound %d entries\n",pointeur-1);
#endif
}
Ejemplo n.º 14
0
/* add option to url of the form:
   "http://host:port/path?option1=val1&option2=val2... */
static void url_add_option(char *buf, int buf_size, const char *fmt, ...)
{
    char buf1[1024];
    va_list ap;

    va_start(ap, fmt);
    if (strchr(buf, '?'))
        pstrcat(buf, buf_size, "&");
    else
        pstrcat(buf, buf_size, "?");
    vsnprintf(buf1, sizeof(buf1), fmt, ap);
    pstrcat(buf, buf_size, buf1);
    va_end(ap);
}
Ejemplo n.º 15
0
/* usage: ModuleControlsACLs actions|all allow|deny user|group list */
MODRET set_modulectrlsacls(cmd_rec *cmd) {
#ifdef PR_USE_CTRLS
  char *bad_action = NULL, **actions = NULL;

  CHECK_ARGS(cmd, 4);
  CHECK_CONF(cmd, CONF_ROOT);

  actions = ctrls_parse_acl(cmd->tmp_pool, cmd->argv[1]);

  if (strcmp(cmd->argv[2], "allow") != 0 &&
      strcmp(cmd->argv[2], "deny") != 0)
    CONF_ERROR(cmd, "second parameter must be 'allow' or 'deny'");

  if (strcmp(cmd->argv[3], "user") != 0 &&
      strcmp(cmd->argv[3], "group") != 0)
    CONF_ERROR(cmd, "third parameter must be 'user' or 'group'");

  bad_action = pr_ctrls_set_module_acls(dso_acttab, dso_pool, actions,
    cmd->argv[2], cmd->argv[3], cmd->argv[4]);
  if (bad_action != NULL)
    CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, ": unknown action: '",
      bad_action, "'", NULL));

  return PR_HANDLED(cmd);
#else
  CONF_ERROR(cmd, "requires Controls support (--enable-ctrls)");
#endif
}
Ejemplo n.º 16
0
/**************************************************************************** **
 prepare to dump a core file - carefully!
 **************************************************************************** */
static BOOL dump_core(void)
{
  char *p;
  pstring dname;
  pstrcpy( dname, debugf );
  if ((p=strrchr(dname,'/')))
    *p=0;
  pstrcat( dname, "/corefiles" );
  mkdir( dname, 0700 );
  sys_chown( dname, getuid(), getgid() );
  chmod( dname, 0700 );
  if ( chdir(dname) )
    return( False );
  umask( ~(0700) );

#ifdef HAVE_GETRLIMIT
#ifdef RLIMIT_CORE
  {
    struct rlimit rlp;
    getrlimit( RLIMIT_CORE, &rlp );
    rlp.rlim_cur = MAX( 4*1024*1024, rlp.rlim_cur );
    setrlimit( RLIMIT_CORE, &rlp );
    getrlimit( RLIMIT_CORE, &rlp );
    DEBUG( 3, ( "Core limits now %d %d\n", (int)rlp.rlim_cur, (int)rlp.rlim_max ) );
  }
#endif
#endif


  DEBUG(0,("Dumping core in %s\n",dname));
  abort();
  return( True );
} /* dump_core */
Ejemplo n.º 17
0
static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
{
    char desc[DESC_SIZE], tmp_desc[DESC_SIZE];
    char *p_name, *tmp_str;
    BDRVVmdkState *s = bs->opaque;
    int ret;

    ret = bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE);
    if (ret < 0) {
        return ret;
    }

    desc[DESC_SIZE - 1] = '\0';
    tmp_str = strstr(desc, "parentCID");
    if (tmp_str == NULL) {
        return -EINVAL;
    }

    pstrcpy(tmp_desc, sizeof(tmp_desc), tmp_str);
    p_name = strstr(desc, "CID");
    if (p_name != NULL) {
        p_name += sizeof("CID");
        snprintf(p_name, sizeof(desc) - (p_name - desc), "%x\n", cid);
        pstrcat(desc, sizeof(desc), tmp_desc);
    }

    ret = bdrv_pwrite_sync(bs->file, s->desc_offset, desc, DESC_SIZE);
    if (ret < 0) {
        return ret;
    }

    return 0;
}
Ejemplo n.º 18
0
/* usage: MemcacheConnectFailures count */
MODRET set_memcacheconnectfailures(cmd_rec *cmd) {
  char *ptr = NULL;
  config_rec *c;
  uint64_t count = 0;

  CHECK_ARGS(cmd, 1);
  CHECK_CONF(cmd, CONF_ROOT|CONF_VIRTUAL|CONF_GLOBAL);

#ifdef HAVE_STRTOULL
  count = strtoull(cmd->argv[1], &ptr, 10);
#else
  count = strtoul(cmd->argv[1], &ptr, 10);
#endif /* HAVE_STRTOULL */

  if (ptr &&
      *ptr) {
    CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, "bad connect failures parameter: ",
      cmd->argv[1], NULL));
  }

  c = add_config_param(cmd->argv[0], 1, NULL);
  c->argv[0] = palloc(c->pool, sizeof(uint64_t));
  *((uint64_t *) c->argv[0]) = count;

  return PR_HANDLED(cmd);
}
Ejemplo n.º 19
0
/* usage:
 *  CounterMaxReaders max
 *  CounterMaxWriters max
 */
MODRET set_countermaxreaderswriters(cmd_rec *cmd) {
  int count;
  config_rec *c;

  CHECK_ARGS(cmd, 1);
  CHECK_CONF(cmd, CONF_ROOT|CONF_VIRTUAL|CONF_GLOBAL|CONF_ANON|CONF_DIR);

  /* A count of zero means that an unlimited number of readers (or writers),
   * as is the default without this module, is in effect.
   */

  count = atoi(cmd->argv[1]);
  if (count < 0 ||
      count > INT_MAX) {
    CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, "invalid number: ", cmd->argv[1],
      NULL));
  }

  c = add_config_param(cmd->argv[0], 1, NULL);
  c->argv[0] = pcalloc(c->pool, sizeof(int));
  *((int *) c->argv[0]) = count;
  c->flags |= CF_MERGEDOWN;

  return PR_HANDLED(cmd);
}
Ejemplo n.º 20
0
/* usage: MemcacheOptions opt1 opt2 ... */
MODRET set_memcacheoptions(cmd_rec *cmd) {
  config_rec *c = NULL;
  register unsigned int i = 0;
  unsigned long opts = 0UL;

  if (cmd->argc-1 == 0) {
    CONF_ERROR(cmd, "wrong number of parameters");
  }

  CHECK_CONF(cmd, CONF_ROOT|CONF_VIRTUAL|CONF_GLOBAL);

  c = add_config_param(cmd->argv[0], 1, NULL);

  for (i = 1; i < cmd->argc; i++) {
    if (strcmp(cmd->argv[i], "NoBinaryProtocol") == 0) {
      opts |= PR_MEMCACHE_FL_NO_BINARY_PROTOCOL;

    } else if (strcmp(cmd->argv[i], "NoRandomReplicaReads") == 0) {
      opts |= PR_MEMCACHE_FL_NO_RANDOM_REPLICA_READ;

    } else {
      CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, ": unknown MemcacheOption '",
        cmd->argv[i], "'", NULL));
    }
  }

  c->argv[0] = pcalloc(c->pool, sizeof(unsigned long));
  *((unsigned long *) c->argv[0]) = opts;

  return PR_HANDLED(cmd);
}
Ejemplo n.º 21
0
/* usage: SFTPPAMOptions opt1 ... */
MODRET set_sftppamoptions(cmd_rec *cmd) {
  config_rec *c = NULL;
  register unsigned int i = 0;
  unsigned long opts = 0UL;

  if (cmd->argc-1 == 0)
    CONF_ERROR(cmd, "wrong number of parameters");

  CHECK_CONF(cmd, CONF_ROOT|CONF_VIRTUAL|CONF_GLOBAL);

  c = add_config_param(cmd->argv[0], 1, NULL);

  for (i = 1; i < cmd->argc; i++) {
    if (strcmp(cmd->argv[i], "NoTTY") == 0) {
      opts |= SFTP_PAM_OPT_NO_TTY;

    } else if (strcmp(cmd->argv[i], "NoInfoMsgs") == 0) {
      opts |= SFTP_PAM_OPT_NO_INFO_MSGS;

    } else if (strcmp(cmd->argv[i], "NoRadioMsgs") == 0) {
      opts |= SFTP_PAM_OPT_NO_RADIO_MSGS;

    } else {
      CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, ": unknown SFTPPAMOption: '",
        cmd->argv[i], "'", NULL));
    }
  }

  c->argv[0] = pcalloc(c->pool, sizeof(unsigned long));
  *((unsigned long *) c->argv[0]) = opts;

  return PR_HANDLED(cmd);
}
Ejemplo n.º 22
0
char *makepath(char *buf, int buf_size, const char *path,
               const char *filename)
{
    pstrcpy(buf, buf_size, path);
    append_slash(buf, buf_size);
    return pstrcat(buf, buf_size, filename);
}
Ejemplo n.º 23
0
Archivo: util.c Proyecto: TheRohans/qi
/* canonize the path and make it absolute */
void canonize_absolute_path(char *buf, int buf_size, const char *path1)
{
    char cwd[MAX_FILENAME_SIZE];
    char path[MAX_FILENAME_SIZE];
    char *homedir;

    if (!is_abs_path(path1)) {
        /* XXX: should call it again */
        if (*path1 == '~' && (path1[1] == '\0' || path1[1] == '/')) {
            homedir = getenv("HOME");
            if (homedir) {
                pstrcpy(path, sizeof(path), homedir);
                pstrcat(path, sizeof(path), path1 + 1);
                goto next;
            }
        }
        /* CG: not sufficient for windows drives */
        getcwd(cwd, sizeof(cwd));
#ifdef WIN32
        path_win_to_unix(cwd);
#endif
        makepath(path, sizeof(path), cwd, path1);
    } else {
        pstrcpy(path, sizeof(path), path1);
    }
next:
    canonize_path(buf, buf_size, path);
}
Ejemplo n.º 24
0
/* canonize the path and make it absolute */
void canonize_absolute_path_old(char *buf, int buf_size, const char *path1)
{
    char path[1024];

    if (!is_abs_path(path1)) {
        /* XXX: should call it again */
        getcwd(path, sizeof(path));
#ifdef WIN32
        path_win_to_unix(path);
#endif
        pstrcat(path, sizeof(path), "/");
        pstrcat(path, sizeof(path), path1);
    } else {
        pstrcpy(path, sizeof(path), path1);
    }
    canonize_path(buf, buf_size, path);
}
Ejemplo n.º 25
0
static BOOL expand_msdfs_target(connection_struct* conn, pstring target)
{
    pstring mapfilename;
    char *filename_start = strchr_m(target, '@');
    char *filename_end;
    int filename_len;
    pstring targethost;
    pstring new_target;

    if (filename_start == NULL) {
        DEBUG(10, ("No filename start in %s\n", target));
        return False;
    }

    filename_end = strchr_m(filename_start+1, '@');

    if (filename_end == NULL) {
        DEBUG(10, ("No filename end in %s\n", target));
        return False;
    }

    filename_len = PTR_DIFF(filename_end, filename_start+1);
    pstrcpy(mapfilename, filename_start+1);
    mapfilename[filename_len] = '\0';

    DEBUG(10, ("Expanding from table [%s]\n", mapfilename));

    if (!read_target_host(mapfilename, targethost)) {
        DEBUG(1, ("Could not expand target host from file %s\n",
                  mapfilename));
        return False;
    }

    standard_sub_conn(conn, mapfilename, sizeof(mapfilename));

    DEBUG(10, ("Expanded targethost to %s\n", targethost));

    *filename_start = '\0';
    pstrcpy(new_target, target);
    pstrcat(new_target, targethost);
    pstrcat(new_target, filename_end+1);

    DEBUG(10, ("New DFS target: %s\n", new_target));
    pstrcpy(target, new_target);
    return True;
}
Ejemplo n.º 26
0
static codepage_p load_client_codepage( int client_codepage )
{
  pstring codepage_file_name;
  unsigned char buf[8];
  FILE *fp = NULL;
  SMB_OFF_T size;
  codepage_p cp_p = NULL;
  SMB_STRUCT_STAT st;

  DEBUG(5, ("load_client_codepage: loading codepage %d.\n", client_codepage));

  if(strlen(CODEPAGEDIR) + 14 > sizeof(codepage_file_name))
  {
    DEBUG(0,("load_client_codepage: filename too long to load\n"));
    return NULL;
  }

  pstrcpy(codepage_file_name, CODEPAGEDIR);
  pstrcat(codepage_file_name, "/");
  pstrcat(codepage_file_name, "codepage.");
  slprintf(&codepage_file_name[strlen(codepage_file_name)], 
	   sizeof(pstring)-(strlen(codepage_file_name)+1),
	   "%03d",
           client_codepage);

  if(sys_stat(codepage_file_name,&st)!=0)
  {
    DEBUG(0,("load_client_codepage: filename %s does not exist.\n",
              codepage_file_name));
    return NULL;
  }

  /* Check if it is at least big enough to hold the required
     data. Should be 2 byte version, 2 byte codepage, 4 byte length, 
     plus zero or more bytes of data. Note that the data cannot be more
     than 4 * MAXCODEPAGELINES bytes.
   */
  size = st.st_size;

  if( size < CODEPAGE_HEADER_SIZE || size > (CODEPAGE_HEADER_SIZE + 4 * MAXCODEPAGELINES))
  {
    DEBUG(0,("load_client_codepage: file %s is an incorrect size for a \
code page file (size=%d).\n", codepage_file_name, (int)size));
    return NULL;
  }
Ejemplo n.º 27
0
/****************************************************************************
add a name to the session users list
****************************************************************************/
void add_session_user(char *user)
{
  fstring suser;
  StrnCpy(suser,user,sizeof(suser)-1);

  if (!Get_Pwnam(suser,True)) return;

  if (suser && *suser && !in_list(suser,session_users,False))
    {
      if (strlen(suser) + strlen(session_users) + 2 >= sizeof(pstring))
	DEBUG(1,("Too many session users??\n"));
      else
	{
	  pstrcat(session_users," ");
	  pstrcat(session_users,suser);
	}
    }
}
int main(void)
{
	char s[MAX] = {"Awesome"};
	char t[] = {" and nice"};

	pstrcat(s,t);
	printf("%s\n", s);
	return 0;
} 
Ejemplo n.º 29
0
static NTSTATUS pdb_init_tdbsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
{
	NTSTATUS nt_status;
	struct tdbsam_privates *tdb_state;

	if (!NT_STATUS_IS_OK(nt_status = make_pdb_methods(pdb_context->mem_ctx, pdb_method))) {
		return nt_status;
	}

	(*pdb_method)->name = "tdbsam";

	(*pdb_method)->setsampwent = tdbsam_setsampwent;
	(*pdb_method)->endsampwent = tdbsam_endsampwent;
	(*pdb_method)->getsampwent = tdbsam_getsampwent;
	(*pdb_method)->getsampwnam = tdbsam_getsampwnam;
	(*pdb_method)->getsampwsid = tdbsam_getsampwsid;
	(*pdb_method)->add_sam_account = tdbsam_add_sam_account;
	(*pdb_method)->update_sam_account = tdbsam_update_sam_account;
	(*pdb_method)->delete_sam_account = tdbsam_delete_sam_account;

	tdb_state = talloc_zero(pdb_context->mem_ctx, sizeof(struct tdbsam_privates));

	if (!tdb_state) {
		DEBUG(0, ("talloc() failed for tdbsam private_data!\n"));
		return NT_STATUS_NO_MEMORY;
	}

	if (location) {
		tdb_state->tdbsam_location = talloc_strdup(pdb_context->mem_ctx, location);
	} else {
		pstring tdbfile;
		get_private_directory(tdbfile);
		pstrcat(tdbfile, "/");
		pstrcat(tdbfile, PASSDB_FILE_NAME);
		tdb_state->tdbsam_location = talloc_strdup(pdb_context->mem_ctx, tdbfile);
	}

	(*pdb_method)->private_data = tdb_state;

	(*pdb_method)->free_private_data = free_private_data;

	return NT_STATUS_OK;
}
Ejemplo n.º 30
0
static const char *get_feature_xml(const char *p, const char **newp,
                                   CPUClass *cc)
{
    size_t len;
    int i;
    const char *name;
    static char target_xml[1024];

    len = 0;
    while (p[len] && p[len] != ':')
        len++;
    *newp = p + len;

    name = NULL;
    if (strncmp(p, "target.xml", len) == 0) {
        /* Generate the XML description for this CPU.  */
        if (!target_xml[0]) {
            GDBRegisterState *r;
            CPUState *cpu = first_cpu;

            snprintf(target_xml, sizeof(target_xml),
                     "<?xml version=\"1.0\"?>"
                     "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"
                     "<target>"
                     "<xi:include href=\"%s\"/>",
                     cc->gdb_core_xml_file);

            for (r = cpu->gdb_regs; r; r = r->next) {
                pstrcat(target_xml, sizeof(target_xml), "<xi:include href=\"");
                pstrcat(target_xml, sizeof(target_xml), r->xml);
                pstrcat(target_xml, sizeof(target_xml), "\"/>");
            }
            pstrcat(target_xml, sizeof(target_xml), "</target>");
        }
        return target_xml;
    }
    for (i = 0; ; i++) {
        name = xml_builtin[i][0];
        if (!name || (strncmp(name, p, len) == 0 && strlen(name) == len))
            break;
    }
    return name ? xml_builtin[i][1] : NULL;
}