metadata: set every bit only once, also bits for unknown attach requests
authorKay Sievers <kay@vrfy.org>
Sat, 21 Dec 2013 02:13:28 +0000 (03:13 +0100)
committerKay Sievers <kay@vrfy.org>
Sat, 21 Dec 2013 02:18:46 +0000 (03:18 +0100)
metadata.c

index dc2e92b1052d2432ddc566164809d7e9e5abb5c8..69d47904649dc2ee64858af40860efd90dc7cdbd 100644 (file)
@@ -379,8 +379,6 @@ int kdbus_meta_append(struct kdbus_meta *meta,
                ret = kdbus_meta_append_timestamp(meta);
                if (ret < 0)
                        goto exit;
-
-               meta->attached |= KDBUS_ATTACH_TIMESTAMP;
        }
 
        if (which & KDBUS_ATTACH_CREDS &&
@@ -388,8 +386,6 @@ int kdbus_meta_append(struct kdbus_meta *meta,
                ret = kdbus_meta_append_cred(meta);
                if (ret < 0)
                        goto exit;
-
-               meta->attached |= KDBUS_ATTACH_CREDS;
        }
 
        if (which & KDBUS_ATTACH_NAMES && conn &&
@@ -397,8 +393,6 @@ int kdbus_meta_append(struct kdbus_meta *meta,
                ret = kdbus_meta_append_src_names(meta, conn);
                if (ret < 0)
                        goto exit;
-
-               meta->attached |= KDBUS_ATTACH_NAMES;
        }
 
        if (which & KDBUS_ATTACH_COMM &&
@@ -414,8 +408,6 @@ int kdbus_meta_append(struct kdbus_meta *meta,
                ret = kdbus_meta_append_str(meta, KDBUS_ITEM_PID_COMM, comm);
                if (ret < 0)
                        goto exit;
-
-               meta->attached |= KDBUS_ATTACH_COMM;
        }
 
        if (which & KDBUS_ATTACH_EXE &&
@@ -424,8 +416,6 @@ int kdbus_meta_append(struct kdbus_meta *meta,
                ret = kdbus_meta_append_exe(meta);
                if (ret < 0)
                        goto exit;
-
-               meta->attached |= KDBUS_ATTACH_EXE;
        }
 
        if (which & KDBUS_ATTACH_CMDLINE &&
@@ -433,8 +423,6 @@ int kdbus_meta_append(struct kdbus_meta *meta,
                ret = kdbus_meta_append_cmdline(meta);
                if (ret < 0)
                        goto exit;
-
-               meta->attached |= KDBUS_ATTACH_CMDLINE;
        }
 
        /* we always return a 4 elements, the element size is 1/4  */
@@ -443,8 +431,6 @@ int kdbus_meta_append(struct kdbus_meta *meta,
                ret = kdbus_meta_append_caps(meta);
                if (ret < 0)
                        goto exit;
-
-               meta->attached |= KDBUS_ATTACH_CAPS;
        }
 
 #ifdef CONFIG_CGROUPS
@@ -454,8 +440,6 @@ int kdbus_meta_append(struct kdbus_meta *meta,
                ret = kdbus_meta_append_cgroup(meta);
                if (ret < 0)
                        goto exit;
-
-               meta->attached |= KDBUS_ATTACH_CGROUP;
        }
 #endif
 
@@ -465,8 +449,6 @@ int kdbus_meta_append(struct kdbus_meta *meta,
                ret = kdbus_meta_append_audit(meta);
                if (ret < 0)
                        goto exit;
-
-               meta->attached |= KDBUS_ATTACH_AUDIT;
        }
 #endif
 
@@ -476,10 +458,13 @@ int kdbus_meta_append(struct kdbus_meta *meta,
                ret = kdbus_meta_append_seclabel(meta);
                if (ret < 0)
                        goto exit;
-
-               meta->attached |= KDBUS_ATTACH_SECLABEL;
        }
 #endif
+       /*
+        * We tried to add everything we got asked for; do not get
+        * here again for the same question.
+        */
+       meta->attached |= which;
 
 exit:
        return ret;