On 09/01/2016 02:32 PM, Lukas Slebodnik wrote:
On (01/09/16 14:28), Michal Židek wrote:
On 09/01/2016 02:13 PM, Lukas Slebodnik wrote:
On (01/09/16 13:15), Michal Židek wrote:
Hi,

see the attached ding-libs patch for ticket #3166.

This is how sssctl config-check prints the merging
issues without this patch:

Messages generated during configuration merging: 2
File blaa did not match provided patterns. Skipping.
File /etc/sssd/conf.d/blaa.conf did not pass access check. Skipping.

And with the patch:

Messages generated during configuration merging: 2
File /etc/sssd/conf.d/blaa did not match provided patterns. Skipping.
File /etc/sssd/conf.d/blaa.conf did not pass access check. Skipping.

Michal

 From 85f54a943d65bd5e9c7863877288ddede8496154 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzi...@redhat.com>
Date: Thu, 1 Sep 2016 12:59:07 +0200
Subject: [PATCH] ini_augment: Use full path when reporting pattern mismatch

We used full path name when reporting access check
failures but only write filename when reporting
on pattern mismatch. This inconsistency does not
look good when the messages are used in sssctl
config-check.

Resolves:
https://fedorahosted.org/sssd/ticket/3166
---
ini/ini.d/merge.validator | 16 ++++++++--------
ini/ini_augment.c         |  3 ++-
2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/ini/ini.d/merge.validator b/ini/ini.d/merge.validator
index dc6d6aa..1defe8e 100644
--- a/ini/ini.d/merge.validator
+++ b/ini/ini.d/merge.validator
@@ -1,11 +1,11 @@
-File merge.validator did not match provided patterns. Skipping.
-File real8.conf did not match provided patterns. Skipping.
-File new_line.conf did not match provided patterns. Skipping.
-File real32be.conf did not match provided patterns. Skipping.
-File real32le.conf did not match provided patterns. Skipping.
-File real16be.conf did not match provided patterns. Skipping.
-File real16le.conf did not match provided patterns. Skipping.
-File foo.conf.in did not match provided patterns. Skipping.
+File %s%s/merge.validator did not match provided patterns. Skipping.
+File %s%s/real8.conf did not match provided patterns. Skipping.
+File %s%s/new_line.conf did not match provided patterns. Skipping.
+File %s%s/real32be.conf did not match provided patterns. Skipping.
+File %s%s/real32le.conf did not match provided patterns. Skipping.
+File %s%s/real16be.conf did not match provided patterns. Skipping.
+File %s%s/real16le.conf did not match provided patterns. Skipping.
+File %s%s/foo.conf.in did not match provided patterns. Skipping.
Errors detected while parsing: %s%s/comment.conf.
Error (9) on line 22: Invalid space character at the beginning of the line.
Error (9) on line 24: Invalid space character at the beginning of the line.
diff --git a/ini/ini_augment.c b/ini/ini_augment.c
index ea3d3da..cced53b 100644
--- a/ini/ini_augment.c
+++ b/ini/ini_augment.c
@@ -470,10 +470,11 @@ static int ini_aug_construct_list(char *dirname ,
              }
          }
          else {
+            snprintf(fullname, PATH_MAX, "%s/%s", dirname, entry->d_name);
Is there any reason why you cannot use functions from libpath_utils ?

LS

This is the method used in the same function already.

Does it mean is good?
libini_config is already linked with libpath_utils.so

[root@graviton ~]# objdump -p /usr/lib64/libini_config.so | grep -i path_utils
   NEEDED               libpath_utils.so.1
   required from libpath_utils.so.1:
     0x076ed981 0x00 16 PATH_UTILS_0.2.1

LS

Attached is a version that uses path_concat. In order to
be consistent I changed it also few lines above.

Btw. I know there are some coding style issues in
the near code, but I decided to leave it the
way it is in order to keep the patch small.

Michal
>From 52f0939f6c84bae8010249ba967e42e149481bcb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzi...@redhat.com>
Date: Thu, 1 Sep 2016 12:59:07 +0200
Subject: [PATCH] ini_augment: Use full path when reporting pattern mismatch

We used full path name when reporting access check
failures but only write filename when reporting
on pattern mismatch. This inconsistency does not
look good when the messages are used in sssctl
config-check.

Resolves:
https://fedorahosted.org/sssd/ticket/3166
---
 ini/ini.d/merge.validator | 16 ++++++++--------
 ini/ini_augment.c         | 15 ++++++++++++---
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/ini/ini.d/merge.validator b/ini/ini.d/merge.validator
index dc6d6aa..1defe8e 100644
--- a/ini/ini.d/merge.validator
+++ b/ini/ini.d/merge.validator
@@ -1,11 +1,11 @@
-File merge.validator did not match provided patterns. Skipping.
-File real8.conf did not match provided patterns. Skipping.
-File new_line.conf did not match provided patterns. Skipping.
-File real32be.conf did not match provided patterns. Skipping.
-File real32le.conf did not match provided patterns. Skipping.
-File real16be.conf did not match provided patterns. Skipping.
-File real16le.conf did not match provided patterns. Skipping.
-File foo.conf.in did not match provided patterns. Skipping.
+File %s%s/merge.validator did not match provided patterns. Skipping.
+File %s%s/real8.conf did not match provided patterns. Skipping.
+File %s%s/new_line.conf did not match provided patterns. Skipping.
+File %s%s/real32be.conf did not match provided patterns. Skipping.
+File %s%s/real32le.conf did not match provided patterns. Skipping.
+File %s%s/real16be.conf did not match provided patterns. Skipping.
+File %s%s/real16le.conf did not match provided patterns. Skipping.
+File %s%s/foo.conf.in did not match provided patterns. Skipping.
 Errors detected while parsing: %s%s/comment.conf.
 Error (9) on line 22: Invalid space character at the beginning of the line.
 Error (9) on line 24: Invalid space character at the beginning of the line.
diff --git a/ini/ini_augment.c b/ini/ini_augment.c
index ea3d3da..4dd4b4d 100644
--- a/ini/ini_augment.c
+++ b/ini/ini_augment.c
@@ -441,8 +441,14 @@ static int ini_aug_construct_list(char *dirname ,
         match = ini_aug_match_name(entry->d_name, ra_regex);
 
         if (match) {
-
-            snprintf(fullname, PATH_MAX, "%s/%s", dirname, entry->d_name);
+            error = path_concat(fullname, PATH_MAX, dirname, entry->d_name);
+            if (error != EOK) {
+                TRACE_ERROR_NUMBER("path_concat failed.", ret);
+                ref_array_destroy(ra_regex);
+                closedir(dir);
+                free(entry);
+                return error;
+            }
 
             if(ini_check_file_perm(fullname, check_perm, ra_err)) {
 
@@ -470,10 +476,13 @@ static int ini_aug_construct_list(char *dirname ,
             }
         }
         else {
+            /* No need to check return value. In case of error
+             * the fullname will be empty string. */
+            path_concat(fullname, PATH_MAX, dirname, entry->d_name);
             ini_aug_add_string(ra_err,
                                "File %s did not match provided patterns."
                                " Skipping.",
-                               entry->d_name);
+                               fullname);
         }
     }
 
-- 
2.5.0

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/admin/lists/sssd-devel@lists.fedorahosted.org

Reply via email to