aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2013-04-23 17:52:26 +0000
committerThierry Vignaud <tv@mageia.org>2013-04-23 17:52:26 +0000
commitd92fefe3c49029478dd5173865da1f3e0752e6e6 (patch)
treea89adaa5c118dbe73ab3420a3f22254058933ca4
parent6fd2bb26cd16adb9a38d37af9dda94ee7baa1c1c (diff)
downloaduserdrake-d92fefe3c49029478dd5173865da1f3e0752e6e6.tar
userdrake-d92fefe3c49029478dd5173865da1f3e0752e6e6.tar.gz
userdrake-d92fefe3c49029478dd5173865da1f3e0752e6e6.tar.bz2
userdrake-d92fefe3c49029478dd5173865da1f3e0752e6e6.tar.xz
userdrake-d92fefe3c49029478dd5173865da1f3e0752e6e6.zip
remove more dead code after previous commit
-rw-r--r--USER/USER.xs154
1 files changed, 0 insertions, 154 deletions
diff --git a/USER/USER.xs b/USER/USER.xs
index 0aa7b61..bb11612 100644
--- a/USER/USER.xs
+++ b/USER/USER.xs
@@ -44,160 +44,6 @@ typedef struct lu_context USER__ADMIN;
typedef struct lu_ent USER__ENT;
typedef struct lu_error USER__ERR;
-static SV ** convert_value_array_list(register SV **sp, GValueArray *array) {
- GValue *value;
- int i;
- long l;
- const char *s;
- for (i = 0; (array != NULL) && (i < array->n_values); i++) {
- value = g_value_array_get_nth(array, i);
- /* If the item is a G_TYPE_LONG, add it as a double. */
- if (G_VALUE_HOLDS_LONG(value)) {
- l = g_value_get_long(value);
- XPUSHs(sv_2mortal(newSViv(l)));
- } else if (G_VALUE_HOLDS_STRING(value)) {
- s = g_value_get_string(value);
- XPUSHs(sv_2mortal(newSVpv(s, 0)));
- }
- }
- return sp;
-}
-
-/* Create a mail spool for the user. */
-int
-lu_mailspool_create_remove(USER__ADMIN *ctx, USER__ENT *ent,
- int action)
-{
- GValueArray *array;
- GValue *value;
- const char *spooldir;
- long uid, gid;
- char *p, *username;
- struct group grp, *err;
- USER__ENT *groupEnt;
- USER__ERR *error = NULL;
- char buf[LINE_MAX * 4];
- int fd;
-
- /* Find the GID of the owner of the file. */
- gid = INVALID;
- groupEnt = lu_ent_new();
- if (lu_group_lookup_name(ctx, "mail", groupEnt, &error)) {
- array = lu_ent_get(groupEnt, LU_GIDNUMBER);
- if (array != NULL) {
- value = g_value_array_get_nth(array, 0);
- if (G_VALUE_HOLDS_LONG(value)) {
- gid = g_value_get_long(value);
- } else
- if (G_VALUE_HOLDS_STRING(value)) {
- gid = strtol(g_value_get_string(value), &p, 0);
- if (*p != '\0') {
- gid = INVALID;
- }
- } else {
- g_assert_not_reached();
- }
- }
- }
- lu_ent_free(groupEnt);
-
- /* Er, okay. Check with libc. */
- if (gid == INVALID) {
- if ((getgrnam_r("mail", &grp, buf, sizeof(buf), &err) == 0) &&
- (err == &grp)) {
- gid = grp.gr_gid;
- }
- }
-
- /* Aiieee. Use the user's group. */
- if (gid == INVALID) {
- array = lu_ent_get(ent, LU_GIDNUMBER);
- if (array != NULL) {
- value = g_value_array_get_nth(array, 0);
- if (G_VALUE_HOLDS_LONG(value)) {
- gid = g_value_get_long(value);
- } else
- if (G_VALUE_HOLDS_STRING(value)) {
- gid = strtol(g_value_get_string(value), &p, 0);
- if (*p == '\0') {
- gid = INVALID;
- }
- } else {
- g_warning("Unable to determine user's GID.");
- g_assert_not_reached();
- }
- }
- }
- g_return_val_if_fail(gid != INVALID, FALSE);
-
- /* Now get the user's UID. */
- array = lu_ent_get(ent, LU_UIDNUMBER);
- if (array != NULL) {
- value = g_value_array_get_nth(array, 0);
- uid = INVALID;
- if (G_VALUE_HOLDS_LONG(value)) {
- uid = g_value_get_long(value);
- } else
- if (G_VALUE_HOLDS_STRING(value)) {
- uid = strtol(g_value_get_string(value), &p, 0);
- if (*p != '\0') {
- uid = INVALID;
- }
- } else {
- g_warning("Unable to determine user's UID.");
- g_assert_not_reached();
- }
- }
- g_return_val_if_fail(uid != INVALID, FALSE);
-
- /* Now get the user's login. */
- username = NULL;
- array = lu_ent_get(ent, LU_USERNAME);
- if (array != NULL) {
- value = g_value_array_get_nth(array, 0);
- if (G_VALUE_HOLDS_LONG(value)) {
- username = g_strdup_printf("%ld",
- g_value_get_long(value));
- } else
- if (G_VALUE_HOLDS_STRING(value)) {
- username = g_value_dup_string(value);
- } else {
- g_warning("Unable to determine user's name.");
- g_assert_not_reached();
- }
- }
- g_return_val_if_fail(username != NULL, FALSE);
-
- /* Get the location of the spool directory. */
- spooldir = lu_cfg_read_single(ctx, "defaults/mailspooldir",
- "/var/mail");
-
- /* That wasn't that hard. Now we just need to create the file. */
- p = g_strdup_printf("%s/%s", spooldir, username);
- g_free(username);
- if (action) {
- fd = open(p, O_WRONLY | O_CREAT, 0);
- if (fd != -1) {
- fchown(fd, uid, gid);
- fchmod(fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
- close(fd);
- g_free(p);
- return 1;
- }
- } else {
- if (unlink(p) == 0) {
- g_free(p);
- return 1;
- }
- if (errno == ENOENT) {
- g_free(p);
- return 1;
- }
- }
- g_free(p);
-
- return 0;
-}
MODULE = USER PACKAGE = USER::ADMIN PREFIX = Admin_