summaryrefslogtreecommitdiff
path: root/server/infopipe/infopipe.c
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-03-04 14:47:33 -0500
committerSimo Sorce <ssorce@redhat.com>2009-03-04 15:18:16 -0500
commit92ebf7d739306c9e3a83af71d616f33173b19b0c (patch)
tree320bd571906076cc8cf93ba6233d57e3abd3aee5 /server/infopipe/infopipe.c
parente84fcf62e9dd948ff2013c133aeb6581ffad4d80 (diff)
downloadsssd-92ebf7d739306c9e3a83af71d616f33173b19b0c.tar.gz
sssd-92ebf7d739306c9e3a83af71d616f33173b19b0c.tar.bz2
sssd-92ebf7d739306c9e3a83af71d616f33173b19b0c.zip
Implement SetUserAttributes in the InfoPipe
SetUserAttributes is now available for use in the Infopipe. I also reorganized a few of the internal InfoPipe objects to reduce code duplication. One very simple test is included in this checkin to validate that the parser is working.
Diffstat (limited to 'server/infopipe/infopipe.c')
-rw-r--r--server/infopipe/infopipe.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/server/infopipe/infopipe.c b/server/infopipe/infopipe.c
index 035bd4b4..272bb166 100644
--- a/server/infopipe/infopipe.c
+++ b/server/infopipe/infopipe.c
@@ -354,6 +354,9 @@ int infp_get_attribute_type(const char *attribute)
{
int attribute_type = INFP_ATTR_TYPE_INVALID;
+ if(attribute == NULL)
+ return INFP_ATTR_TYPE_INVALID;
+
if(strcasecmp(attribute, "defaultgroup") == 0)
attribute_type = INFP_ATTR_TYPE_DEFAULTGROUP;
else if (strcasecmp(attribute, "gecos") == 0) {
@@ -576,6 +579,64 @@ einval:
return EOK;
}
+int infp_get_ldb_val_from_dbus(TALLOC_CTX *mem_ctx, DBusMessageIter *iter, struct ldb_val **value, int dbus_type, int subtype)
+{
+ struct ldb_val *val = NULL;
+ void *tmp;
+ size_t element_size;
+ int num_elements;
+ int ret;
+
+ val = talloc_zero(mem_ctx, struct ldb_val);
+ if (val == NULL) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ /* Fixed-size types */
+ if (sbus_is_dbus_fixed_type(dbus_type)) {
+ dbus_message_iter_get_basic(iter, &tmp);
+ val->length = sbus_get_dbus_type_size(dbus_type);
+ }
+
+ else if (sbus_is_dbus_string_type(dbus_type)) {
+ dbus_message_iter_get_basic(iter, &tmp);
+ val->length = strlen((const char *)tmp);
+ }
+
+ else if (dbus_type == DBUS_TYPE_ARRAY) {
+ if (!sbus_is_dbus_fixed_type(subtype)) {
+ ret = EINVAL;
+ goto done;
+ }
+
+ element_size = sbus_get_dbus_type_size(subtype);
+ dbus_message_iter_get_fixed_array(iter, &tmp, &num_elements);
+ val->length = num_elements * element_size;
+ }
+ else {
+ /* Unsupported type */
+ ret = EINVAL;
+ goto done;
+ }
+
+ val->data = talloc_memdup(val, tmp, val->length);
+ if (val->data == NULL) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ *value = val;
+ ret = EOK;
+
+done:
+ if (ret != EOK) {
+ talloc_free(val);
+ *value = NULL;
+ }
+ return ret;
+}
+
int main(int argc, const char *argv[])
{
int opt;