Ejemplo n.º 1
0
Archivo: str.c Proyecto: Einheri/wl500g
static void
str_split_text_common(struct mystr* p_src, struct mystr* p_rhs,
                      const char* p_text, int is_reverse)
{
  struct str_locate_result locate_result;
  unsigned int indexx;
  unsigned int search_len = vsf_sysutil_strlen(p_text);
  if (is_reverse)
  {
    locate_result = str_locate_text_reverse(p_src, p_text);
  }
  else
  {
    locate_result = str_locate_text(p_src, p_text);
  }
  /* Not found? */
  if (!locate_result.found)
  {
    str_empty(p_rhs);
    return;
  }
  indexx = locate_result.index;
  if (indexx + search_len > p_src->len)
  {
    bug("indexx invalid in str_split_text");
  } 
  /* Build rhs */
  private_str_alloc_memchunk(p_rhs, p_src->p_buf + indexx + search_len,
                             p_src->len - indexx - search_len);
  /* Build lhs */
  str_trunc(p_src, indexx);
}
Ejemplo n.º 2
0
static void
calculate_chdir_dir(int anon, struct mystr* p_chroot_str,
                    struct mystr* p_chdir_str,
                    const struct mystr* p_user_str)
{
  if (anon && tunable_anon_root)
  {
    str_alloc_text(p_chroot_str, tunable_anon_root);
  }
  else if (!anon && tunable_local_root)
  {
    str_alloc_text(p_chroot_str, tunable_local_root);
  }
  /* If enabled, the chroot() location embedded in the HOMEDIR takes
   * precedence.
   */
  if (!anon && tunable_passwd_chroot_enable)
  {
    struct mystr homedir_str = INIT_MYSTR;
    const struct vsf_sysutil_user* p_user = str_getpwnam(p_user_str);
    struct str_locate_result loc_result;
    if (p_user == 0)
    {
      die2("cannot locate user entry:", str_getbuf(p_user_str));
    }
    str_alloc_text(&homedir_str, vsf_sysutil_user_get_homedir(p_user));
    loc_result = str_locate_text(&homedir_str, "/./");
    if (loc_result.found)
    {
      str_split_text(&homedir_str, p_chdir_str, "/./");
      str_copy(p_chroot_str, &homedir_str);
    }
    str_free(&homedir_str);
  }
}
Ejemplo n.º 3
0
Archivo: str.c Proyecto: Einheri/wl500g
struct str_locate_result
str_locate_char(const struct mystr* p_str, char look_char)
{
  char look_str[2];
  look_str[0] = look_char;
  look_str[1] = '\0';
  return str_locate_text(p_str, look_str);
}
Ejemplo n.º 4
0
Archivo: str.c Proyecto: Einheri/wl500g
struct str_locate_result
str_locate_str(const struct mystr* p_str, const struct mystr* p_look_str)
{
  return str_locate_text(p_str, str_getbuf(p_look_str));
}