Exemplo n.º 1
0
static VALUE
rb_shadow_sgetspent(VALUE self, VALUE str)
{
  struct spwd *entry;
  VALUE result;

  if( TYPE(str) != T_STRING )
    rb_raise(rb_eException,"argument must be a string.");

  entry = sgetspent(StringValuePtr(str));

  if( entry == NULL )
    return Qnil;

  result = rb_struct_new(rb_sPasswdEntry,
		      rb_tainted_str_new2(entry->sp_namp),
		      rb_tainted_str_new2(entry->sp_pwdp),
		      INT2FIX(entry->sp_lstchg),
		      INT2FIX(entry->sp_min),
		      INT2FIX(entry->sp_max),
		      INT2FIX(entry->sp_warn),
		      INT2FIX(entry->sp_inact),
		      INT2FIX(entry->sp_expire),
		      INT2FIX(entry->sp_flag),
		      0);
  free(entry);
  return result;
};
Exemplo n.º 2
0
void testValues() {
    f = 2;
    
    struct spwd * result = sgetspent(anystring());
    //@ assert result != \null ==> \valid_read(result->sp_namp);

    //@ assert f == 2;
    //@ assert vacuous: \false;
}
Exemplo n.º 3
0
/* fgetspent - get an entry from an /etc/shadow formatted stream */
struct spwd *fgetspent(FILE *fp)
{
	char buf[BUFSIZ];
	char *cp;

	if (!fp)
		/* return (0); */
		return NULL;

	if (fgets(buf, sizeof buf, fp) != (char *) 0) {
		if ((cp = strchr(buf, '\n')))
			*cp = '\0';
		return (sgetspent(buf));
	}
	/* return 0; */
	return NULL;
}
Exemplo n.º 4
0
static VALUE
rb_shadow_sgetspent(VALUE self, VALUE str)
{
    struct spwd *entry;
    VALUE result;

    if( TYPE(str) != T_STRING )
        rb_raise(rb_eException,"argument must be a string.");

    entry = sgetspent(StringValuePtr(str));

    if( entry == NULL )
        return Qnil;

    result = convert_pw_struct( entry );
    free(entry);
    return result;
};
Exemplo n.º 5
0
static void *
shadow_parse(const char *line)
{
	return (void *) sgetspent(line);
}
Exemplo n.º 6
0
void runFailure() {
    sgetspent(NULL);
}
Exemplo n.º 7
0
void runSuccess() {
    sgetspent(anystring());
}