From 9fd9d32ba647cf5e3fe0fba010f301de716f9b47 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Thu, 17 May 2012 13:54:29 -0400
Subject: [PATCH] Always use positional arguments in translatable strings

https://fedorahosted.org/sssd/ticket/1336
---
 src/sss_client/pam_sss.c  |    4 ++--
 src/tools/sss_cache.c     |   10 +++++-----
 src/tools/sss_groupdel.c  |    2 +-
 src/tools/sss_groupmod.c  |    4 ++--
 src/tools/sss_groupshow.c |   10 +++++-----
 src/tools/sss_useradd.c   |    6 +++---
 src/tools/sss_userdel.c   |    8 ++++----
 src/tools/sss_usermod.c   |    4 ++--
 src/tools/tools_util.h    |    2 +-
 9 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/src/sss_client/pam_sss.c b/src/sss_client/pam_sss.c
index e25792fc012c587e2ffc804057a2b43ec6b90068..9dca7e3c7b2f773abf08d5127d63b0bfc52ed06e 100644
--- a/src/sss_client/pam_sss.c
+++ b/src/sss_client/pam_sss.c
@@ -637,7 +637,7 @@ static int user_info_grace_login(pam_handle_t *pamh,
     memcpy(&grace, buf + sizeof(uint32_t), sizeof(uint32_t));
     ret = snprintf(user_msg, sizeof(user_msg),
                    _("Your password has expired. "
-                     "You have %d grace login(s) remaining."),
+                     "You have %1$d grace login(s) remaining."),
                    grace);
     if (ret < 0 || ret >= sizeof(user_msg)) {
         D(("snprintf failed."));
@@ -682,7 +682,7 @@ static int user_info_expire_warn(pam_handle_t *pamh,
     }
 
     ret = snprintf(user_msg, sizeof(user_msg),
-                   _("Your password will expire in %d %s."), expire, unit);
+                   _("Your password will expire in %1$d %2$s."), expire, unit);
     if (ret < 0 || ret >= sizeof(user_msg)) {
         D(("snprintf failed."));
         return PAM_SYSTEM_ERR;
diff --git a/src/tools/sss_cache.c b/src/tools/sss_cache.c
index d0f2b28714140a068ed43d22e0b0bf75feb804e3..1b2b29fe774b58bc15bf51ec0560a681382bc66d 100644
--- a/src/tools/sss_cache.c
+++ b/src/tools/sss_cache.c
@@ -169,10 +169,10 @@ bool invalidate_entries(TALLOC_CTX *ctx, struct sysdb_ctx *sysdb,
               ("Searching for %s with filter %s failed\n",
                type_rec.type_string, filter));
         if (name) {
-            ERROR("No such %s named %s, skipping\n",
+            ERROR("No such %1$s named %2$s, skipping\n",
                     type_rec.type_string, name);
         } else {
-            ERROR("No objects of type %s in the cache, skipping\n",
+            ERROR("No objects of type %1$s in the cache, skipping\n",
                     type_rec.type_string);
         }
         return false;
@@ -184,14 +184,14 @@ bool invalidate_entries(TALLOC_CTX *ctx, struct sysdb_ctx *sysdb,
         if (c_name == NULL) {
             DEBUG(SSSDBG_MINOR_FAILURE,
                   ("Something bad happened, can't find attribute %s", SYSDB_NAME));
-            ERROR("Couldn't invalidate %s", type_rec.type_string);
+            ERROR("Couldn't invalidate %1$s", type_rec.type_string);
             iret = false;
         } else {
             ret = invalidate_entry(ctx, sysdb, c_name, entry_type);
             if (ret != EOK) {
                 DEBUG(SSSDBG_MINOR_FAILURE,
                       ("Couldn't invalidate %s %s", type_rec.type_string, c_name));
-                ERROR("Couldn't invalidate %s %s", type_rec.type_string, c_name);
+                ERROR("Couldn't invalidate %1$s %2$s", type_rec.type_string, c_name);
                 iret = false;
             }
         }
@@ -452,7 +452,7 @@ errno_t init_context(int argc, const char *argv[], struct cache_tool_ctx **tctx)
     ret = init_domains(ctx, domain);
     if (ret != EOK) {
         if (domain) {
-            ERROR("Could not open domain %s\n", domain);
+            ERROR("Could not open domain %1$s\n", domain);
         } else {
             ERROR("Could not open available domains\n");
         }
diff --git a/src/tools/sss_groupdel.c b/src/tools/sss_groupdel.c
index 09f73504df9039a38879ba16e7d8628741176ec8..70030cab4f38b89cfbb61d896a04903eeac311f0 100644
--- a/src/tools/sss_groupdel.c
+++ b/src/tools/sss_groupdel.c
@@ -98,7 +98,7 @@ int main(int argc, const char **argv)
 
     if ((tctx->octx->gid < tctx->local->id_min) ||
         (tctx->local->id_max && tctx->octx->gid > tctx->local->id_max)) {
-        ERROR("Group %s is outside the defined ID range for domain\n",
+        ERROR("Group %1$s is outside the defined ID range for domain\n",
               tctx->octx->name);
         ret = EXIT_FAILURE;
         goto fini;
diff --git a/src/tools/sss_groupmod.c b/src/tools/sss_groupmod.c
index 47134aedf78354aa1107cf30e01fc1fcbe2abc4f..abab4f57f644215e130b787a176bf4b9a72d9e44 100644
--- a/src/tools/sss_groupmod.c
+++ b/src/tools/sss_groupmod.c
@@ -152,7 +152,7 @@ int main(int argc, const char **argv)
         /* Check group names in the LOCAL domain */
         ret = check_group_names(tctx, tctx->octx->addgroups, &badgroup);
         if (ret != EOK) {
-            ERROR("Cannot find group %s in local domain, "
+            ERROR("Cannot find group %1$s in local domain, "
                   "only groups in local domain are allowed\n", badgroup);
             ret = EXIT_FAILURE;
             goto fini;
@@ -179,7 +179,7 @@ int main(int argc, const char **argv)
         /* Check group names in the LOCAL domain */
         ret = check_group_names(tctx, tctx->octx->rmgroups, &badgroup);
         if (ret != EOK) {
-            ERROR("Cannot find group %s in local domain, "
+            ERROR("Cannot find group %1$s in local domain, "
                   "only groups in local domain are allowed\n", badgroup);
             ret = EXIT_FAILURE;
             goto fini;
diff --git a/src/tools/sss_groupshow.c b/src/tools/sss_groupshow.c
index 764e32416b046dfc6ff2a47de37627e40b0109f0..0eecd3a9671c1aae5ced8e8fa35f4ab6a3310075 100644
--- a/src/tools/sss_groupshow.c
+++ b/src/tools/sss_groupshow.c
@@ -559,26 +559,26 @@ static void print_group_info(struct group_info *g, int level)
     snprintf(fmt, 8, "%%%ds", level*PADDING_SPACES);
     snprintf(padding, 512, fmt, "");
 
-    printf(_("%s%sGroup: %s\n"), padding,
+    printf(_("%1$s%2$sGroup: %3$s\n"), padding,
                                  g->mpg ? _("Magic Private ") : "",
                                  g->name);
-    printf(_("%sGID number: %d\n"), padding, g->gid);
+    printf(_("%1$sGID number: %2$d\n"), padding, g->gid);
 
-    printf(_("%sMember users: "), padding);
+    printf(_("%1$sMember users: "), padding);
     if (g->user_members) {
         for (i=0; g->user_members[i]; ++i) {
             printf("%s%s", i>0 ? "," : "",
                            g->user_members[i]);
         }
     }
-    printf(_("\n%sIs a member of: "), padding);
+    printf(_("\n%1$sIs a member of: "), padding);
     if (g->memberofs) {
         for (i=0; g->memberofs[i]; ++i) {
             printf("%s%s", i>0 ? "," : "",
                            g->memberofs[i]);
         }
     }
-    printf(_("\n%sMember groups: "), padding);
+    printf(_("\n%1$sMember groups: "), padding);
 }
 
 static void print_recursive(struct group_info **group_members, int level)
diff --git a/src/tools/sss_useradd.c b/src/tools/sss_useradd.c
index 5ca2612a351bb060f172434ace3bce9c7e022a1d..4df7c098e554d4b8c924961305f35492bfba3807 100644
--- a/src/tools/sss_useradd.c
+++ b/src/tools/sss_useradd.c
@@ -150,7 +150,7 @@ int main(int argc, const char **argv)
         /* Check group names in the LOCAL domain */
         ret = check_group_names(tctx, tctx->octx->addgroups, &badgroup);
         if (ret != EOK) {
-            ERROR("Cannot find group %s in local domain\n", badgroup);
+            ERROR("Cannot find group %1$s in local domain\n", badgroup);
             ret = EXIT_FAILURE;
             goto fini;
         }
@@ -229,7 +229,7 @@ int main(int argc, const char **argv)
             ERROR("User's home directory already exists, not copying "
                   "data from skeldir\n");
         } else if (ret != EOK) {
-            ERROR("Cannot create user's home directory: %s\n", strerror(ret));
+            ERROR("Cannot create user's home directory: %1$s\n", strerror(ret));
             ret = EXIT_FAILURE;
             goto fini;
         }
@@ -240,7 +240,7 @@ int main(int argc, const char **argv)
                                 tctx->octx->uid,
                                 tctx->octx->gid);
         if (ret != EOK) {
-            ERROR("Cannot create user's mail spool: %s\n", strerror(ret));
+            ERROR("Cannot create user's mail spool: %1$s\n", strerror(ret));
             DEBUG(1, ("Cannot create user's mail spool: [%d][%s].\n",
                         ret, strerror(ret)));
             ret = EXIT_FAILURE;
diff --git a/src/tools/sss_userdel.c b/src/tools/sss_userdel.c
index 6d5e8295877afee3106e2a9d978504697f870d46..0d1c63e4ce58544775ae28041c65443ac054ee0d 100644
--- a/src/tools/sss_userdel.c
+++ b/src/tools/sss_userdel.c
@@ -227,7 +227,7 @@ int main(int argc, const char **argv)
 
     if ((tctx->octx->uid < tctx->local->id_min) ||
         (tctx->local->id_max && tctx->octx->uid > tctx->local->id_max)) {
-        ERROR("User %s is outside the defined ID range for domain\n",
+        ERROR("User %1$s is outside the defined ID range for domain\n",
               tctx->octx->name);
         ret = EXIT_FAILURE;
         goto fini;
@@ -264,7 +264,7 @@ int main(int argc, const char **argv)
                 break;
 
             case EOK:
-                ERROR("WARNING: The user (uid %lu) was still logged in when "
+                ERROR("WARNING: The user (uid %1$lu) was still logged in when "
                       "deleted.\n", (unsigned long) tctx->octx->uid);
                 break;
 
@@ -281,7 +281,7 @@ int main(int argc, const char **argv)
 
     ret = run_userdel_cmd(tctx);
     if (ret != EOK) {
-        ERROR("The post-delete command failed: %s\n", strerror(ret));
+        ERROR("The post-delete command failed: %1$s\n", strerror(ret));
         goto fini;
     }
 
@@ -295,7 +295,7 @@ int main(int argc, const char **argv)
         if (ret == EPERM) {
             ERROR("Not removing home dir - not owned by user\n");
         } else if (ret != EOK) {
-            ERROR("Cannot remove homedir: %s\n", strerror(ret));
+            ERROR("Cannot remove homedir: %1$s\n", strerror(ret));
             ret = EXIT_FAILURE;
             goto fini;
         }
diff --git a/src/tools/sss_usermod.c b/src/tools/sss_usermod.c
index dfcde9e56c632b6ddee0ec5cf375258c713ac360..b761de225de5842624d8f888bb0d7053617eb37d 100644
--- a/src/tools/sss_usermod.c
+++ b/src/tools/sss_usermod.c
@@ -173,7 +173,7 @@ int main(int argc, const char **argv)
         /* Check group names in the LOCAL domain */
         ret = check_group_names(tctx, tctx->octx->addgroups, &badgroup);
         if (ret != EOK) {
-            ERROR("Cannot find group %s in local domain, "
+            ERROR("Cannot find group %1$s in local domain, "
                   "only groups in local domain are allowed\n", badgroup);
             ret = EXIT_FAILURE;
             goto fini;
@@ -200,7 +200,7 @@ int main(int argc, const char **argv)
         /* Check group names in the LOCAL domain */
         ret = check_group_names(tctx, tctx->octx->rmgroups, &badgroup);
         if (ret != EOK) {
-            ERROR("Cannot find group %s in local domain, "
+            ERROR("Cannot find group %1$s in local domain, "
                   "only groups in local domain are allowed\n", badgroup);
             ret = EXIT_FAILURE;
             goto fini;
diff --git a/src/tools/tools_util.h b/src/tools/tools_util.h
index fccd9d96bdc293f85d4af2ebcb0756a1fcc940cc..fd26b89056cf16b974102b5163e7ee76608a2d2e 100644
--- a/src/tools/tools_util.h
+++ b/src/tools/tools_util.h
@@ -37,7 +37,7 @@
     val = getuid(); \
     if (val != 0) { \
         DEBUG(1, ("Running under %d, must be root\n", val)); \
-        ERROR("%s must be run as root\n", prg_name); \
+        ERROR("%1$s must be run as root\n", prg_name); \
         val = EXIT_FAILURE; \
         goto fini; \
     } \
-- 
1.7.10.1

