aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--USER/USER.xs111
1 files changed, 106 insertions, 5 deletions
diff --git a/USER/USER.xs b/USER/USER.xs
index e7d9e60..2177f8a 100644
--- a/USER/USER.xs
+++ b/USER/USER.xs
@@ -536,16 +536,28 @@ Admin_UserAdd(self, ent, is_system, dont_create_home)
OUTPUT:
RETVAL
+void
+Admin_UserModify(self, ent)
+ USER::ADMIN *self
+ USER::ENT *ent
+ PPCODE:
+ struct lu_error *error = NULL;
+ if (lu_user_modify(self, ent, &error) == FALSE) {
+ croak("Group could not be modified %s.\n", error ? error->string : "Unknown error");
+ }
+
int
Admin_UserDel(self, ent)
USER::ADMIN *self
USER::ENT *ent
- PPCODE:
- USER__ERR *error;
+ CODE:
+ USER__ERR *error = NULL;
if (lu_user_delete(self, ent, &error) == FALSE) {
croak("User Could Not be deleted: %s.\n", error ? error->string : "Unknown error");
RETVAL = 0;
} else RETVAL = 1 ;
+ OUTPUT:
+ RETVAL
void
Admin_UserEdit(self, ent)
@@ -638,26 +650,38 @@ Admin_GroupAdd(self, ent)
USER::ENT *ent
PPCODE:
struct lu_error *error = NULL;
- GValue value;
if (lu_group_add(self, ent, &error) == FALSE) {
warn("Group creation failed.\n");
}
void
-Admin_GroupDel(self, ent)
+Admin_GroupModify(self, ent)
USER::ADMIN *self
USER::ENT *ent
PPCODE:
+ struct lu_error *error = NULL;
+ if (lu_group_modify(self, ent, &error) == FALSE) {
+ croak("Group could not be modified %s.\n", error ? error->string : "Unknown error");
+ }
+
+int
+Admin_GroupDel(self, ent)
+ USER::ADMIN *self
+ USER::ENT *ent
+ CODE:
USER__ERR *error;
if (lu_group_delete(self, ent, &error) == FALSE) {
croak("Group could not be deleted: %s.\n", error ? error->string : "Unknown error");
RETVAL = 0;
} else RETVAL = 1 ;
+ OUTPUT:
+ RETVAL
+
void
Admin_GroupEdit(self, ent)
USER::ADMIN *self
USER::ENT *ent
-
+
void
Admin_InitGroup(self, name, is_system)
USER::ADMIN *self
@@ -761,6 +785,30 @@ Admin_GetUserShells(self)
OUTPUT:
RETVAL
+void
+Admin_Clean(self, ent)
+ USER::ADMIN *self
+ USER::ENT *ent
+ PPCODE:
+ USER__ERR *error = NULL;
+ GValueArray *values;
+ GValue *value;
+ const char *tmp = NULL;
+ values = lu_ent_get(ent, LU_HOMEDIRECTORY);
+ if ((values == NULL) || (values->n_values == 0)) {
+ warn("No home directory for the user.\n");
+ } else {
+ value = g_value_array_get_nth(values, 0);
+ tmp = g_value_get_string(value);
+ if (lu_homedir_remove(tmp, &error) == FALSE) {
+ croak("Home Directory Could Not be deleted: %s.\n", error ? error->string : "Unknown error");
+ }
+ }
+ /* Delete the mail spool for the user. */
+ if (lu_mailspool_create_remove(self, ent, 0) != 1) {
+ warn(_("Error deleting mail spool.\n"));
+ }
+
MODULE = USER PACKAGE = USER::ENT PREFIX = Ent_
USER::ENT *
@@ -853,6 +901,59 @@ Ent_GroupName(self, ssv)
warn("XS_GroupName: Cannot make operation on LU_GROUPNAME attribute");
}
+AV*
+Ent_MemberName(self, rv, AddOrDel)
+ USER::ENT *self
+ SV *rv
+ int AddOrDel
+ CODE:
+ GValueArray *members;
+ GValue *value, val;
+ RETVAL = (AV*)sv_2mortal((SV*)newAV());
+ char **member = NULL;
+ int c;
+ if ( SvIOK(rv) && SvIV(rv) == 1) {
+ members = lu_ent_get(self, LU_MEMBERNAME);
+ for (c = 0; (members != NULL) && (c < members->n_values); c++) {
+ if( av_store(RETVAL, c, newSVpv(g_value_get_string(g_value_array_get_nth(members, c)), 0)) == NULL ){
+ warn("XS_MemberName: failed to store elements of array");
+ }
+ }
+ } else if ( SvPOK( rv ) ) {
+ memset(&val, 0, sizeof(val));
+ g_value_init(&val, G_TYPE_STRING);
+ if (AddOrDel == 1) {
+ member = g_strsplit(SvPV(rv, PL_na), ",", 0);
+ if (member) {
+ for (c = 0; member && member[c]; c++) {
+ g_value_set_string(&val, member[c]);
+ lu_ent_add(self, LU_MEMBERNAME, &val);
+ g_value_reset(&val);
+ }
+ lu_hup_nscd();
+ g_strfreev(member);
+ member = NULL;
+ }
+ } else if (AddOrDel == 2) {
+ member = g_strsplit(SvPV(rv, PL_na), ",", 0);
+ if (member) {
+ for (c = 0; member && member[c]; c++) {
+ g_value_set_string(&val, member[c]);
+ lu_ent_del(self, LU_MEMBERNAME, &val);
+ g_value_reset(&val);
+ }
+ lu_hup_nscd();
+ g_strfreev(member);
+ member = NULL;
+ }
+ g_value_unset(&val);
+ }
+ } else {
+ croak("XS_MemberName: Cannot make operation on LU_MEMBERNAME attribute");
+ };
+ OUTPUT:
+ RETVAL
+
void
Ent_Uid(self, ssv)
USER::ENT *self