[systemd-devel] [PATCH 1/2] Fix --no-ask-password
Jan Janssen
medhefgo at web.de
Fri May 17 06:38:12 PDT 2013
---
src/hostname/hostnamectl.c | 6 +++---
src/locale/localectl.c | 12 ++++++++----
src/timedate/timedatectl.c | 14 +++++++++-----
3 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c
index 064581a..7c45ce5 100644
--- a/src/hostname/hostnamectl.c
+++ b/src/hostname/hostnamectl.c
@@ -219,7 +219,7 @@ static int show_status(DBusConnection *bus, char **args, unsigned n) {
static int set_hostname(DBusConnection *bus, char **args, unsigned n) {
_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
- dbus_bool_t interactive = true;
+ dbus_bool_t interactive = arg_ask_password;
_cleanup_free_ char *h = NULL;
const char *hostname = args[1];
int r;
@@ -311,7 +311,7 @@ static int set_hostname(DBusConnection *bus, char **args, unsigned n) {
static int set_icon_name(DBusConnection *bus, char **args, unsigned n) {
_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
- dbus_bool_t interactive = true;
+ dbus_bool_t interactive = arg_ask_password;
assert(args);
assert(n == 2);
@@ -333,7 +333,7 @@ static int set_icon_name(DBusConnection *bus, char **args, unsigned n) {
static int set_chassis(DBusConnection *bus, char **args, unsigned n) {
_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
- dbus_bool_t interactive = true;
+ dbus_bool_t interactive = arg_ask_password;
assert(args);
assert(n == 2);
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index 50250c4..422ac2c 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -223,7 +223,7 @@ static int show_status(DBusConnection *bus, char **args, unsigned n) {
static int set_locale(DBusConnection *bus, char **args, unsigned n) {
_cleanup_dbus_message_unref_ DBusMessage *m = NULL, *reply = NULL;
- dbus_bool_t interactive = true;
+ dbus_bool_t interactive = arg_ask_password;
DBusError error;
DBusMessageIter iter;
int r;
@@ -459,7 +459,7 @@ static int list_locales(DBusConnection *bus, char **args, unsigned n) {
static int set_vconsole_keymap(DBusConnection *bus, char **args, unsigned n) {
_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
- dbus_bool_t interactive = true, b;
+ dbus_bool_t interactive = arg_ask_password, b;
const char *map, *toggle_map;
assert(bus);
@@ -565,7 +565,7 @@ static int list_vconsole_keymaps(DBusConnection *bus, char **args, unsigned n) {
static int set_x11_keymap(DBusConnection *bus, char **args, unsigned n) {
_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
- dbus_bool_t interactive = true, b;
+ dbus_bool_t interactive = arg_ask_password, b;
const char *layout, *model, *variant, *options;
assert(bus);
@@ -757,7 +757,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
- while ((c = getopt_long(argc, argv, "has:H:P", options, NULL)) >= 0) {
+ while ((c = getopt_long(argc, argv, "hH:P", options, NULL)) >= 0) {
switch (c) {
@@ -787,6 +787,10 @@ static int parse_argv(int argc, char *argv[]) {
arg_no_pager = true;
break;
+ case ARG_NO_ASK_PASSWORD:
+ arg_ask_password = false;
+ break;
+
case '?':
return -EINVAL;
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
index 8d4e560..37e0a4f 100644
--- a/src/timedate/timedatectl.c
+++ b/src/timedate/timedatectl.c
@@ -304,7 +304,7 @@ static int show_status(DBusConnection *bus, char **args, unsigned n) {
static int set_time(DBusConnection *bus, char **args, unsigned n) {
_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
- dbus_bool_t relative = false, interactive = true;
+ dbus_bool_t relative = false, interactive = arg_ask_password;
usec_t t;
dbus_int64_t u;
int r;
@@ -338,7 +338,7 @@ static int set_time(DBusConnection *bus, char **args, unsigned n) {
static int set_timezone(DBusConnection *bus, char **args, unsigned n) {
_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
- dbus_bool_t interactive = true;
+ dbus_bool_t interactive = arg_ask_password;
assert(args);
assert(n == 2);
@@ -360,7 +360,7 @@ static int set_timezone(DBusConnection *bus, char **args, unsigned n) {
static int set_local_rtc(DBusConnection *bus, char **args, unsigned n) {
_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
- dbus_bool_t interactive = true, b, q;
+ dbus_bool_t interactive = arg_ask_password, b, q;
int r;
assert(args);
@@ -393,7 +393,7 @@ static int set_local_rtc(DBusConnection *bus, char **args, unsigned n) {
static int set_ntp(DBusConnection *bus, char **args, unsigned n) {
_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
- dbus_bool_t interactive = true, b;
+ dbus_bool_t interactive = arg_ask_password, b;
int r;
assert(args);
@@ -540,7 +540,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
- while ((c = getopt_long(argc, argv, "+hH:P", options, NULL)) >= 0) {
+ while ((c = getopt_long(argc, argv, "hH:P", options, NULL)) >= 0) {
switch (c) {
@@ -562,6 +562,10 @@ static int parse_argv(int argc, char *argv[]) {
arg_host = optarg;
break;
+ case ARG_NO_ASK_PASSWORD:
+ arg_ask_password = false;
+ break;
+
case ARG_ADJUST_SYSTEM_CLOCK:
arg_adjust_system_clock = true;
break;
--
1.8.2.3
More information about the systemd-devel
mailing list