aboutsummaryrefslogtreecommitdiffstats
path: root/USER/USER.xs
diff options
context:
space:
mode:
authorDaouda Lo <daouda@mandriva.com>2003-06-19 08:45:29 +0000
committerDaouda Lo <daouda@mandriva.com>2003-06-19 08:45:29 +0000
commit8cd3ec0f6d120741683070fab1adcdded50dcc81 (patch)
treebe34fd91a4009510dce52a7d93f04126e9adf434 /USER/USER.xs
parentedbea9de5c0e8e1cd45e1c75af8f6cb0eb33f031 (diff)
downloaduserdrake-8cd3ec0f6d120741683070fab1adcdded50dcc81.tar
userdrake-8cd3ec0f6d120741683070fab1adcdded50dcc81.tar.gz
userdrake-8cd3ec0f6d120741683070fab1adcdded50dcc81.tar.bz2
userdrake-8cd3ec0f6d120741683070fab1adcdded50dcc81.tar.xz
userdrake-8cd3ec0f6d120741683070fab1adcdded50dcc81.zip
- unlock , islocked and lock implementations
Diffstat (limited to 'USER/USER.xs')
-rw-r--r--USER/USER.xs126
1 files changed, 96 insertions, 30 deletions
diff --git a/USER/USER.xs b/USER/USER.xs
index 2177f8a..8249708 100644
--- a/USER/USER.xs
+++ b/USER/USER.xs
@@ -536,14 +536,50 @@ Admin_UserAdd(self, ent, is_system, dont_create_home)
OUTPUT:
RETVAL
+int
+Admin_IsLocked(self, ent)
+ USER::ADMIN *self
+ USER::ENT *ent
+ CODE:
+ USER__ERR *error = NULL;
+ if (lu_user_islocked(self, ent, &error))
+ RETVAL = 1
+ else RETVAL = 0;
+ OUPUT:
+ RETVAL
+
+int
+Admin_Lock(self, ent)
+ USER::ADMIN *self
+ USER::ENT *ent
+ CODE:
+ USER__ERR *error = NULL;
+ if (lu_user_lock(self, ent, &error) == FALSE)
+ RETVAL = 0
+ else RETVAL = 1
+ OUTPUT:
+ RETVAL
+
+int
+Admin_UnLock(self, ent)
+ USER::ADMIN *self
+ USER::ENT *ent
+ CODE:
+ USER__ERR *error = NULL;
+ if (lu_user_unlock(self, ent, &error) == FALSE)
+ RETVAL = 0
+ else RETVAL = 1
+ OUTPUT:
+ RETVAL
+
void
Admin_UserModify(self, ent)
USER::ADMIN *self
USER::ENT *ent
PPCODE:
- struct lu_error *error = NULL;
+ USER__ERR *error = NULL;
if (lu_user_modify(self, ent, &error) == FALSE) {
- croak("Group could not be modified %s.\n", error ? error->string : "Unknown error");
+ croak("User could not be modified %s.\n", error ? error->string : "Unknown error");
}
int
@@ -560,11 +596,6 @@ Admin_UserDel(self, ent)
RETVAL
void
-Admin_UserEdit(self, ent)
- USER::ADMIN *self
- USER::ENT *ent
-
-void
Admin_InitUser(self, name, is_system)
USER::ADMIN *self
char *name
@@ -582,7 +613,7 @@ Admin_UserSetPass(self, ent, userPasswd)
char *userPasswd
PPCODE:
USER__ERR *error = NULL;
- gboolean crypted = FALSE;
+ gboolean crypted = TRUE;
if (lu_user_setpass(self, ent, userPasswd, crypted, &error) == FALSE) {
croak("Failed to set password %s.\n", error ? error->string : _("unknown error"));
if (error) { lu_error_free(&error); }
@@ -649,7 +680,7 @@ Admin_GroupAdd(self, ent)
USER::ADMIN *self
USER::ENT *ent
PPCODE:
- struct lu_error *error = NULL;
+ USER__ERR *error = NULL;
if (lu_group_add(self, ent, &error) == FALSE) {
warn("Group creation failed.\n");
}
@@ -659,7 +690,7 @@ Admin_GroupModify(self, ent)
USER::ADMIN *self
USER::ENT *ent
PPCODE:
- struct lu_error *error = NULL;
+ USER__ERR *error = NULL;
if (lu_group_modify(self, ent, &error) == FALSE) {
croak("Group could not be modified %s.\n", error ? error->string : "Unknown error");
}
@@ -669,7 +700,7 @@ Admin_GroupDel(self, ent)
USER::ADMIN *self
USER::ENT *ent
CODE:
- USER__ERR *error;
+ USER__ERR *error = NULL;
if (lu_group_delete(self, ent, &error) == FALSE) {
croak("Group could not be deleted: %s.\n", error ? error->string : "Unknown error");
RETVAL = 0;
@@ -678,11 +709,6 @@ Admin_GroupDel(self, ent)
RETVAL
void
-Admin_GroupEdit(self, ent)
- USER::ADMIN *self
- USER::ENT *ent
-
-void
Admin_InitGroup(self, name, is_system)
USER::ADMIN *self
char *name
@@ -731,6 +757,44 @@ Admin_EnumerateGroupsByUser(self, name)
OUTPUT:
RETVAL
+AV *
+Admin_UsersEnumerate(self)
+ USER::ADMIN *self
+ CODE:
+ int c;
+ USER__ERR *error = NULL;
+ const char *pattern = NULL;
+ RETVAL = (AV*)sv_2mortal((SV*)newAV());
+ GValueArray *users;
+ users = lu_users_enumerate(self, pattern, &error);
+ for (c = 0; ( users != NULL) && (c < users->n_values); c++) {
+ if( av_store(RETVAL, c, newSVpv(g_value_get_string(g_value_array_get_nth(users, c)), 0)) == NULL ){
+ warn("XS_UserEnumerate: failed to store elements of array");
+ }
+ }
+ g_value_array_free(users);
+ OUTPUT:
+ RETVAL
+
+AV *
+Admin_GroupsEnumerate(self)
+ USER::ADMIN *self
+ CODE:
+ int c;
+ USER__ERR *error = NULL;
+ const char *pattern = NULL;
+ RETVAL = (AV*)sv_2mortal((SV*)newAV());
+ GValueArray *groups;
+ groups = lu_groups_enumerate(self, pattern, &error);
+ for (c = 0; (groups != NULL) && (c < groups->n_values); c++) {
+ if( av_store(RETVAL, c, newSVpv(g_value_get_string(g_value_array_get_nth(groups, c)), 0)) == NULL ){
+ warn("XS_GroupEnumerate: failed to store elements of array");
+ }
+ }
+ g_value_array_free(groups);
+ OUTPUT:
+ RETVAL
+
AV *
Admin_UsersEnumerateFull(self)
USER::ADMIN *self
@@ -1127,22 +1191,24 @@ Ent_ShadowWarn(self, ssv)
PPCODE:
GValueArray *values;
GValue *value, val;
- if ( SvIOK(ssv) && SvIV(ssv) == -65533) {
- values = lu_ent_get(self, LU_SHADOWWARNING);
- if (values != NULL) {
- value = g_value_array_get_nth(values, 0);
- if (G_VALUE_HOLDS_STRING(value)) {
- XPUSHs(sv_2mortal(newSVpv(g_value_get_string(value), 0)));
- } else if (G_VALUE_HOLDS_LONG(value)) {
- XPUSHs(sv_2mortal(newSVpv(g_strdup_printf("%ld", g_value_get_long(value)), 0)));
+ if ( SvIOK(ssv) ) {
+ if (SvIV(ssv) == -65533) {
+ values = lu_ent_get(self, LU_SHADOWWARNING);
+ if (values != NULL) {
+ value = g_value_array_get_nth(values, 0);
+ if (G_VALUE_HOLDS_LONG(value)) {
+ XPUSHs(sv_2mortal(newSViv(g_value_get_long(value))));
+ } else if (G_VALUE_HOLDS_STRING(value)) {
+ XPUSHs(sv_2mortal(newSViv(atol(g_value_get_string(value)))));
+ }
}
+ } else {
+ memset(&val, 0, sizeof(val));
+ g_value_init(&val, G_TYPE_LONG);
+ g_value_set_long(&val, (long)SvIV( ssv ));
+ lu_ent_clear(self, LU_SHADOWWARNING);
+ lu_ent_add(self, LU_SHADOWWARNING, &val);
}
- } else if( SvPOK( ssv ) ) {
- memset(&val, 0, sizeof(val));
- g_value_init(&val, G_TYPE_STRING);
- g_value_set_string(&val, SvPV(ssv,PL_na));
- lu_ent_clear(self, LU_SHADOWWARNING);
- lu_ent_add(self, LU_SHADOWWARNING, &val);
} else {
warn("XS_ShadowWarn: Cannot make operation on LU_SHADOWWARNING attribute");
}