projects
/
platform
/
upstream
/
connman.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Reply all multiple/simultaenous SetDevicePower method call" into tizen
[platform/upstream/connman.git]
/
scripts
/
openvpn-script.c
diff --git
a/scripts/openvpn-script.c
b/scripts/openvpn-script.c
old mode 100644
(file)
new mode 100755
(executable)
index
8d2c3ff
..
6ba0d29
--- a/
scripts/openvpn-script.c
+++ b/
scripts/openvpn-script.c
@@
-2,8
+2,8
@@
*
* Connection Manager
*
*
* Connection Manager
*
- * Copyright (C) 2007-201
0
Intel Corporation. All rights reserved.
- * Copyright (C) 2010
BMW Car IT GmbH. All rights reserved
.
+ * Copyright (C) 2007-201
2
Intel Corporation. All rights reserved.
+ * Copyright (C) 2010
,2012-2014 BMW Car IT GmbH
.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@
-27,11
+27,22
@@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <syslog.h>
+#include <libgen.h>
#include <dbus/dbus.h>
extern char **environ;
#include <dbus/dbus.h>
extern char **environ;
+static void print(const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ vsyslog(LOG_INFO, format, ap);
+ va_end(ap);
+}
+
static void append(DBusMessageIter *dict, const char *pattern)
{
DBusMessageIter entry;
static void append(DBusMessageIter *dict, const char *pattern)
{
DBusMessageIter entry;
@@
-61,6
+72,9
@@
int main(int argc, char *argv[])
DBusMessage *msg;
DBusMessageIter iter, dict;
char **envp, *busname, *interface, *path, *reason;
DBusMessage *msg;
DBusMessageIter iter, dict;
char **envp, *busname, *interface, *path, *reason;
+ int ret = 0;
+
+ openlog(basename(argv[0]), LOG_NDELAY | LOG_PID, LOG_DAEMON);
busname = getenv("CONNMAN_BUSNAME");
interface = getenv("CONNMAN_INTERFACE");
busname = getenv("CONNMAN_BUSNAME");
interface = getenv("CONNMAN_INTERFACE");
@@
-69,27
+83,31
@@
int main(int argc, char *argv[])
reason = getenv("script_type");
if (!busname || !interface || !path || !reason) {
reason = getenv("script_type");
if (!busname || !interface || !path || !reason) {
- fprintf(stderr, "Required environment variables not set\n");
- return 1;
+ print("Required environment variables not set; "
+ "bus=%s iface=%s path=%s reason=%s",
+ busname, interface, path, reason);
+ ret = 1;
+ goto out;
}
dbus_error_init(&error);
conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
}
dbus_error_init(&error);
conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
- if (
conn == NULL
) {
- if (dbus_error_is_set(&error)
== TRUE
) {
-
fprintf(stderr, "%s\n
", error.message);
+ if (
!conn
) {
+ if (dbus_error_is_set(&error)) {
+
print("%s
", error.message);
dbus_error_free(&error);
} else
dbus_error_free(&error);
} else
- fprintf(stderr, "Failed to get on system bus\n");
- return 0;
+ print("Failed to get on system bus");
+
+ goto out;
}
msg = dbus_message_new_method_call(busname, path,
interface, "notify");
}
msg = dbus_message_new_method_call(busname, path,
interface, "notify");
- if (
msg == NULL
) {
+ if (
!msg
) {
dbus_connection_unref(conn);
dbus_connection_unref(conn);
-
fprintf(stderr, "Failed to allocate method call\n
");
-
return 0
;
+
print("Failed to allocate method call
");
+
goto out
;
}
dbus_message_set_no_reply(msg, TRUE);
}
dbus_message_set_no_reply(msg, TRUE);
@@
-110,8
+128,10
@@
int main(int argc, char *argv[])
dbus_message_iter_close_container(&iter, &dict);
dbus_message_iter_close_container(&iter, &dict);
- if (dbus_connection_send(conn, msg, NULL) == FALSE)
- fprintf(stderr, "Failed to send message\n");
+ if (!dbus_connection_send(conn, msg, NULL)) {
+ print("Failed to send message");
+ goto out;
+ }
dbus_connection_flush(conn);
dbus_connection_flush(conn);
@@
-119,5
+139,8
@@
int main(int argc, char *argv[])
dbus_connection_unref(conn);
dbus_connection_unref(conn);
- return 0;
+out:
+ closelog();
+
+ return ret;
}
}