]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - attribute.c
Make rc4 encryption/decryption more explicit.
[paraslash.git] / attribute.c
index 655c286697a6ca68c94da410ec5841276dd97ef5..ff284c3ad7e7822b136e7b788c8f13d17c40888b 100644 (file)
@@ -1,12 +1,16 @@
 /*
- * Copyright (C) 1997-2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1997-2009 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
 /** \file attribute.c Attribute handling functions. */
+
+#include <openssl/rc4.h>
+
 #include "para.h"
 #include "error.h"
+#include "crypt.h"
 #include "string.h"
 #include "afh.h"
 #include "afs.h"
@@ -127,13 +131,13 @@ static int print_attribute(struct osl_table *table, struct osl_row *row,
 {
        struct lsatt_action_data *laad = data;
        struct osl_object bitnum_obj;
-       int ret, ret2;
+       int ret;
 
        if (!(laad->flags & LSATT_FLAG_LONG))
                return para_printf(&laad->pb, "%s\n", name);
        ret = osl_get_object(table, row, ATTCOL_BITNUM, &bitnum_obj);
        if (ret < 0) {
-               ret2 = para_printf(&laad->pb, "%s: %s\n", name, para_strerror(-ret));
+               para_printf(&laad->pb, "%s: %s\n", name, para_strerror(-ret));
                return ret;
        }
        return para_printf(&laad->pb, "%u\t%s\n", *(unsigned char*)bitnum_obj.data,
@@ -171,7 +175,7 @@ static void com_lsatt_callback(int fd, const struct osl_object *query)
        free(laad.pb.buf);
 }
 
-int com_lsatt(int fd, int argc, char * const * const argv)
+int com_lsatt(struct rc4_context *rc4c, int argc, char * const * const argv)
 {
        unsigned flags = 0;
        struct osl_object options = {.data = &flags, .size = sizeof(flags)};
@@ -199,12 +203,12 @@ int com_lsatt(int fd, int argc, char * const * const argv)
                }
        }
        ret = send_option_arg_callback_request(&options, argc - i, argv + i,
-               com_lsatt_callback, send_result, &fd);
+               com_lsatt_callback, rc4_send_result, rc4c);
        if (!ret) {
                if (argc > 1)
-                       ret = send_va_buffer(fd, "no matches\n");
+                       ret = rc4_send_va_buffer(rc4c, "no matches\n");
        } else if (ret < 0)
-               send_va_buffer(fd, "%s\n", para_strerror(-ret));
+               rc4_send_va_buffer(rc4c, "%s\n", para_strerror(-ret));
        return ret;
 }
 
@@ -272,7 +276,7 @@ out:
                PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
 }
 
-int com_setatt(__a_unused int fd, int argc, char * const * const argv)
+int com_setatt(__a_unused struct rc4_context *rc4c, int argc, char * const * const argv)
 {
        if (argc < 3)
                return -E_ATTR_SYNTAX;
@@ -288,7 +292,7 @@ struct addatt_event_data {
 
 static void com_addatt_callback(int fd, const struct osl_object *query)
 {
-       char *p = query->data;
+       char *p;
        int ret = 1, ret2 = 0;
        struct para_buffer pb = {
                .max_size = SHMMAX,
@@ -347,22 +351,22 @@ static void com_addatt_callback(int fd, const struct osl_object *query)
        }
 out:
        if (ret < 0 && ret2 >= 0)
-               ret = para_printf(&pb, "%s: %s\n", p, para_strerror(-ret));
+               para_printf(&pb, "%s: %s\n", p, para_strerror(-ret));
        if (pb.offset)
                pass_buffer_as_shm(pb.buf, pb.offset, &fd);
        free(pb.buf);
 }
 
-int com_addatt(int fd, int argc, char * const * const argv)
+int com_addatt(struct rc4_context *rc4c, int argc, char * const * const argv)
 {
        int ret;
 
        if (argc < 2)
                return -E_ATTR_SYNTAX;
        ret = send_standard_callback_request(argc - 1, argv + 1, com_addatt_callback,
-               send_result, &fd);
+               rc4_send_result, rc4c);
        if (ret < 0)
-               send_va_buffer(fd, "%s\n", para_strerror(-ret));
+               rc4_send_va_buffer(rc4c, "%s\n", para_strerror(-ret));
        return ret;
 }
 
@@ -388,7 +392,7 @@ static void com_mvatt_callback(int fd, const struct osl_object *query)
        ret = osl_update_object(attribute_table, row, ATTCOL_NAME, &obj);
 out:
        if (ret < 0)
-               ret = para_printf(&pb, "%s\n", para_strerror(-ret));
+               para_printf(&pb, "%s\n", para_strerror(-ret));
        else
                afs_event(ATTRIBUTE_RENAME, &pb, NULL);
        if (pb.offset)
@@ -396,16 +400,16 @@ out:
        free(pb.buf);
 }
 
-int com_mvatt(int fd, int argc, char * const * const argv)
+int com_mvatt(struct rc4_context *rc4c, int argc, char * const * const argv)
 {
        int ret;
 
        if (argc != 3)
                return -E_ATTR_SYNTAX;
        ret = send_standard_callback_request(argc - 1, argv + 1, com_mvatt_callback,
-               send_result, &fd);
+               rc4_send_result, rc4c);
        if (ret < 0)
-               send_va_buffer(fd, "%s\n", para_strerror(-ret));
+               rc4_send_va_buffer(rc4c, "%s\n", para_strerror(-ret));
        return ret;
 }
 
@@ -468,16 +472,16 @@ static void com_rmatt_callback(int fd, const struct osl_object *query)
        free(raad.pb.buf);
 }
 
-int com_rmatt(int fd, int argc, char * const * const argv)
+int com_rmatt(struct rc4_context *rc4c, int argc, char * const * const argv)
 {
        int ret;
 
        if (argc < 2)
                return -E_ATTR_SYNTAX;
        ret = send_standard_callback_request(argc - 1, argv + 1, com_rmatt_callback,
-               send_result, &fd);
+               rc4_send_result, rc4c);
        if (ret < 0)
-               send_va_buffer(fd, "%s\n", para_strerror(-ret));
+               rc4_send_va_buffer(rc4c, "%s\n", para_strerror(-ret));
        return ret;
 }
 
@@ -568,8 +572,7 @@ void attribute_close(void)
 /**
  * Open the attribute table.
  *
- * \param ti Gets initialized by this function.
- * \param db The database directory.
+ * \param dir The database directory.
  *
  * \return Positive on success, negative on errors.
  *
@@ -598,7 +601,11 @@ static int attribute_create(const char *dir)
        return osl_create_table(&attribute_table_desc);
 }
 
-
+/**
+ * Initialize the attribute table structure.
+ *
+ * \param t The table structure to initialize.
+ */
 void attribute_init(struct afs_table *t)
 {
        t->name = attribute_table_desc.name;