From 1b4d931b8ed4614cb0800273103b40ecae5a9576 Mon Sep 17 00:00:00 2001 From: Frank Benkstein Date: Sat, 17 Jan 2009 15:37:29 +0100 Subject: [PATCH] uncrustify all source files --- src/auth-pam.c | 59 ++++++++++++----------- src/auth-shadow.c | 33 ++++++------- src/console_switch.c | 1 + src/logging.c | 25 ++++++---- src/module.c | 35 +++++++------- src/module.h | 17 +++++-- src/plugin.c | 49 ++++++++++--------- src/plugin.h | 20 +++++--- src/plugins.c | 129 +++++++++++++++++++++++++++------------------------ src/process.c | 60 ++++++++++++------------ src/process.h | 3 +- src/prompt.c | 32 +++++++------ src/prompt.h | 4 +- src/script.c | 66 ++++++++++++++------------ src/script.h | 17 +++++-- src/signals.c | 32 +++++++------ src/terminal.c | 1 + src/tsort.c | 14 +++--- src/tsort.h | 3 +- src/util.c | 9 ++-- src/vlock-main.c | 69 +++++++++++++++++---------- 21 files changed, 379 insertions(+), 299 deletions(-) diff --git a/src/auth-pam.c b/src/auth-pam.c index 012735c..fc72fb3 100644 --- a/src/auth-pam.c +++ b/src/auth-pam.c @@ -57,7 +57,8 @@ GQuark vlock_auth_error_quark(void) return g_quark_from_static_string("vlock-auth-pam-error-quark"); } -struct conversation_data { +struct conversation_data +{ GError *error; struct timespec *timeout; }; @@ -84,12 +85,16 @@ static int conversation(int num_msg, const struct pam_message **msg, struct for (int i = 0; i < num_msg; i++) { switch (msg[i]->msg_style) { case PAM_PROMPT_ECHO_OFF: - aresp[i].resp = prompt_echo_off(msg[i]->msg, conv_data->timeout, &conv_data->error); + aresp[i].resp = prompt_echo_off(msg[i]->msg, + conv_data->timeout, + &conv_data->error); if (aresp[i].resp == NULL) goto fail; break; case PAM_PROMPT_ECHO_ON: - aresp[i].resp = prompt(msg[i]->msg, conv_data->timeout, &conv_data->error); + aresp[i].resp = prompt(msg[i]->msg, + conv_data->timeout, + &conv_data->error); if (aresp[i].resp == NULL) goto fail; break; @@ -149,10 +154,10 @@ bool auth(const char *user, struct timespec *timeout, GError **error) if (pam_status != PAM_SUCCESS) { g_propagate_error(error, - g_error_new_literal( - VLOCK_AUTH_ERROR, - VLOCK_AUTH_ERROR_FAILED, - pam_strerror(pamh, pam_status))); + g_error_new_literal( + VLOCK_AUTH_ERROR, + VLOCK_AUTH_ERROR_FAILED, + pam_strerror(pamh, pam_status))); goto end; } @@ -165,10 +170,10 @@ bool auth(const char *user, struct timespec *timeout, GError **error) if (pam_status != PAM_SUCCESS) { g_propagate_error(error, - g_error_new_literal( - VLOCK_AUTH_ERROR, - VLOCK_AUTH_ERROR_FAILED, - pam_strerror(pamh, pam_status))); + g_error_new_literal( + VLOCK_AUTH_ERROR, + VLOCK_AUTH_ERROR_FAILED, + pam_strerror(pamh, pam_status))); goto end; } } @@ -184,36 +189,36 @@ bool auth(const char *user, struct timespec *timeout, GError **error) g_assert(conv_data.error != NULL); g_propagate_error(error, conv_data.error); } else if (pam_status == PAM_AUTH_ERR || - pam_status == PAM_USER_UNKNOWN || - pam_status == PAM_MAXTRIES) { + pam_status == PAM_USER_UNKNOWN || + pam_status == PAM_MAXTRIES) { g_assert(conv_data.error == NULL); g_propagate_error(error, - g_error_new_literal( - VLOCK_AUTH_ERROR, - VLOCK_AUTH_ERROR_DENIED, - "Authentication failure")); + g_error_new_literal( + VLOCK_AUTH_ERROR, + VLOCK_AUTH_ERROR_DENIED, + "Authentication failure")); } else if (pam_status != PAM_SUCCESS) { g_assert(conv_data.error == NULL); g_propagate_error(error, - g_error_new_literal( - VLOCK_AUTH_ERROR, - VLOCK_AUTH_ERROR_FAILED, - pam_strerror(pamh, pam_status))); + g_error_new_literal( + VLOCK_AUTH_ERROR, + VLOCK_AUTH_ERROR_FAILED, + pam_strerror(pamh, pam_status))); } end: /* finish pam */ pam_end_status = pam_end(pamh, pam_status); - if (pam_end_status != PAM_SUCCESS && error != NULL && *error == NULL) { + if (pam_end_status != PAM_SUCCESS && error != NULL && *error == NULL) g_propagate_error(error, - g_error_new_literal( - VLOCK_AUTH_ERROR, - VLOCK_AUTH_ERROR_FAILED, - pam_strerror(pamh, pam_status))); - } + g_error_new_literal( + VLOCK_AUTH_ERROR, + VLOCK_AUTH_ERROR_FAILED, + pam_strerror(pamh, pam_status))); return (pam_end_status == PAM_SUCCESS && pam_status == PAM_SUCCESS); } + diff --git a/src/auth-shadow.c b/src/auth-shadow.c index 0c36e4c..9b18911 100644 --- a/src/auth-shadow.c +++ b/src/auth-shadow.c @@ -51,10 +51,10 @@ bool auth(const char *user, struct timespec *timeout, GError **error) /* format the prompt */ if (asprintf(&msg, "%s's Password: ", user) < 0) { g_propagate_error(error, - g_error_new_literal( - VLOCK_AUTH_ERROR, - VLOCK_AUTH_ERROR_FAILED, - g_strerror(errno))); + g_error_new_literal( + VLOCK_AUTH_ERROR, + VLOCK_AUTH_ERROR_FAILED, + g_strerror(errno))); return false; } @@ -69,20 +69,20 @@ bool auth(const char *user, struct timespec *timeout, GError **error) goto auth_error; g_set_error(error, - VLOCK_AUTH_ERROR, - VLOCK_AUTH_ERROR_FAILED, - "Could not get shadow record: %s", - g_strerror(errno)); + VLOCK_AUTH_ERROR, + VLOCK_AUTH_ERROR_FAILED, + "Could not get shadow record: %s", + g_strerror(errno)); goto shadow_error; } /* hash the password */ if ((cryptpw = crypt(pwd, spw->sp_pwdp)) == NULL) { g_set_error(error, - VLOCK_AUTH_ERROR, - VLOCK_AUTH_ERROR_FAILED, - "crypt() failed: %s", - g_strerror(errno)); + VLOCK_AUTH_ERROR, + VLOCK_AUTH_ERROR_FAILED, + "crypt() failed: %s", + g_strerror(errno)); goto shadow_error; } @@ -92,10 +92,10 @@ bool auth(const char *user, struct timespec *timeout, GError **error) auth_error: sleep(1); g_propagate_error(error, - g_error_new_literal( - VLOCK_AUTH_ERROR, - VLOCK_AUTH_ERROR_DENIED, - "Authentication failure")); + g_error_new_literal( + VLOCK_AUTH_ERROR, + VLOCK_AUTH_ERROR_DENIED, + "Authentication failure")); } shadow_error: @@ -113,3 +113,4 @@ prompt_error: return result; } + diff --git a/src/console_switch.c b/src/console_switch.c index 5e9d020..3312bef 100644 --- a/src/console_switch.c +++ b/src/console_switch.c @@ -127,3 +127,4 @@ bool unlock_console_switch(void) return false; } } + diff --git a/src/logging.c b/src/logging.c index 4e5ee19..88ddaf8 100644 --- a/src/logging.c +++ b/src/logging.c @@ -6,9 +6,9 @@ #include "logging.h" static void vlock_log_handler(const gchar *log_domain, - GLogLevelFlags __attribute__((unused)) log_level, - const gchar *message, - gpointer __attribute__((unused)) user_data) + GLogLevelFlags __attribute__((unused)) log_level, + const gchar *message, + gpointer __attribute__((unused)) user_data) { /* XXX: observe the log level (maybe look at some environment variable) */ if (log_domain != NULL) @@ -18,18 +18,19 @@ static void vlock_log_handler(const gchar *log_domain, } static void vlock_error_log_handler(const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer __attribute__((unused)) user_data) + GLogLevelFlags log_level, + const gchar *message, + gpointer __attribute__((unused)) user_data) { vlock_log_handler(log_domain, log_level, message, NULL); abort(); } static void vlock_critical_log_handler(const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer __attribute__((unused)) user_data) + GLogLevelFlags log_level, + const gchar *message, + gpointer __attribute__( + (unused)) user_data) { vlock_log_handler(log_domain, log_level, message, NULL); exit(1); @@ -38,6 +39,10 @@ static void vlock_critical_log_handler(const gchar *log_domain, void vlock_initialize_logging(void) { g_log_set_handler(NULL, G_LOG_LEVEL_ERROR, vlock_error_log_handler, NULL); - g_log_set_handler(NULL, G_LOG_LEVEL_CRITICAL, vlock_critical_log_handler, NULL); + g_log_set_handler(NULL, + G_LOG_LEVEL_CRITICAL, + vlock_critical_log_handler, + NULL); g_log_set_default_handler(vlock_log_handler, NULL); } + diff --git a/src/module.c b/src/module.c index f6d0f16..71b96b3 100644 --- a/src/module.c +++ b/src/module.c @@ -38,7 +38,9 @@ G_DEFINE_TYPE(VlockModule, vlock_module, TYPE_VLOCK_PLUGIN) -#define VLOCK_MODULE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), TYPE_VLOCK_MODULE, VlockModulePrivate)) +#define VLOCK_MODULE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj),\ + TYPE_VLOCK_MODULE,\ + VlockModulePrivate)) /* A hook function as defined by a module. */ typedef bool (*module_hook_function)(void **); @@ -68,16 +70,16 @@ static bool vlock_module_open(VlockPlugin *plugin, GError **error) * runs as a setuid executable and would otherwise override restrictions. */ if (access(path, R_OK) < 0) { gint error_code = (errno == ENOENT) ? - VLOCK_PLUGIN_ERROR_NOT_FOUND : - VLOCK_PLUGIN_ERROR_FAILED; + VLOCK_PLUGIN_ERROR_NOT_FOUND : + VLOCK_PLUGIN_ERROR_FAILED; g_set_error( - error, - VLOCK_PLUGIN_ERROR, - error_code, - "could not open module '%s': %s", - plugin->name, - g_strerror(errno)); + error, + VLOCK_PLUGIN_ERROR, + error_code, + "could not open module '%s': %s", + plugin->name, + g_strerror(errno)); g_free(path); return false; @@ -90,19 +92,19 @@ static bool vlock_module_open(VlockPlugin *plugin, GError **error) if (dl_handle == NULL) { g_set_error( - error, - VLOCK_PLUGIN_ERROR, - VLOCK_PLUGIN_ERROR_FAILED, - "could not open module '%s': %s", - plugin->name, - dlerror()); + error, + VLOCK_PLUGIN_ERROR, + VLOCK_PLUGIN_ERROR_FAILED, + "could not open module '%s': %s", + plugin->name, + dlerror()); return false; } /* Load all the hooks. Unimplemented hooks are NULL and will not be called later. */ for (size_t i = 0; i < nr_hooks; i++) - *(void **) (&self->priv->hooks[i]) = dlsym(dl_handle, hooks[i].name); + *(void **)(&self->priv->hooks[i]) = dlsym(dl_handle, hooks[i].name); /* Load all dependencies. Unspecified dependencies are NULL. */ for (size_t i = 0; i < nr_dependencies; i++) { @@ -169,3 +171,4 @@ static void vlock_module_class_init(VlockModuleClass *klass) plugin_class->open = vlock_module_open; plugin_class->call_hook = vlock_module_call_hook; } + diff --git a/src/module.h b/src/module.h index 23831ad..8c15957 100644 --- a/src/module.h +++ b/src/module.h @@ -7,11 +7,18 @@ * Module type macros. */ #define TYPE_VLOCK_MODULE (vlock_module_get_type()) -#define VLOCK_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_VLOCK_MODULE, VlockModule)) -#define VLOCK_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_VLOCK_MODULE, VlockModuleClass)) -#define IS_VLOCK_MODULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_VLOCK_MODULE)) -#define IS_VLOCK_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_VLOCK_MODULE)) -#define VLOCK_MODULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_VLOCK_MODULE, VlockModuleClass)) +#define VLOCK_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_VLOCK_MODULE,\ + VlockModule)) +#define VLOCK_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\ + TYPE_VLOCK_MODULE,\ + VlockModuleClass)) +#define IS_VLOCK_MODULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\ + TYPE_VLOCK_MODULE)) +#define IS_VLOCK_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\ + TYPE_VLOCK_MODULE)) +#define VLOCK_MODULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),\ + TYPE_VLOCK_MODULE,\ + VlockModuleClass)) typedef struct _VlockModule VlockModule; typedef struct _VlockModuleClass VlockModuleClass; diff --git a/src/plugin.c b/src/plugin.c index dedc51f..6e40836 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -37,10 +37,9 @@ static void vlock_plugin_init(VlockPlugin *self) } /* Create new plugin object. */ -static GObject *vlock_plugin_constructor( - GType gtype, - guint n_properties, - GObjectConstructParam *properties) +static GObject *vlock_plugin_constructor(GType gtype, + guint n_properties, + GObjectConstructParam *properties) { GObjectClass *parent_class = G_OBJECT_CLASS(vlock_plugin_parent_class); GObject *object = parent_class->constructor(gtype, n_properties, properties); @@ -63,7 +62,8 @@ static void vlock_plugin_finalize(GObject *object) for (size_t i = 0; i < nr_dependencies; i++) { while (self->dependencies[i] != NULL) { g_free(self->dependencies[i]->data); - self->dependencies[i] = g_list_delete_link(self->dependencies[i], self->dependencies[i]); + self->dependencies[i] = g_list_delete_link(self->dependencies[i], + self->dependencies[i]); } } @@ -88,11 +88,10 @@ static void vlock_plugin_set_name(VlockPlugin *self, const gchar *name) } /* Set properties. */ -static void vlock_plugin_set_property( - GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) +static void vlock_plugin_set_property(GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) { VlockPlugin *self = VLOCK_PLUGIN(object); @@ -109,11 +108,10 @@ static void vlock_plugin_set_property( } /* Get properties. */ -static void vlock_plugin_get_property( - GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +static void vlock_plugin_get_property(GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { VlockPlugin *self = VLOCK_PLUGIN(object); @@ -146,18 +144,18 @@ static void vlock_plugin_class_init(VlockPluginClass *klass) /* Install properties. */ vlock_plugin_param_spec = g_param_spec_string( - "name", - "plugin name", - "Set the plugin's name", - NULL, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE - ); + "name", + "plugin name", + "Set the plugin's name", + NULL, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE + ); g_object_class_install_property( - gobject_class, - PROP_VLOCK_PLUGIN_NAME, - vlock_plugin_param_spec - ); + gobject_class, + PROP_VLOCK_PLUGIN_NAME, + vlock_plugin_param_spec + ); } bool vlock_plugin_open(VlockPlugin *self, GError **error) @@ -173,3 +171,4 @@ bool vlock_plugin_call_hook(VlockPlugin *self, const gchar *hook_name) g_assert(klass->call_hook != NULL); return klass->call_hook(self, hook_name); } + diff --git a/src/plugin.h b/src/plugin.h index 47e884f..ff69dfa 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -46,11 +46,18 @@ enum { * Plugin type macros. */ #define TYPE_VLOCK_PLUGIN (vlock_plugin_get_type()) -#define VLOCK_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_VLOCK_PLUGIN, VlockPlugin)) -#define VLOCK_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_VLOCK_PLUGIN, VlockPluginClass)) -#define IS_VLOCK_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_VLOCK_PLUGIN)) -#define IS_VLOCK_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_VLOCK_PLUGIN)) -#define VLOCK_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_VLOCK_PLUGIN, VlockPluginClass)) +#define VLOCK_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_VLOCK_PLUGIN,\ + VlockPlugin)) +#define VLOCK_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\ + TYPE_VLOCK_PLUGIN,\ + VlockPluginClass)) +#define IS_VLOCK_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\ + TYPE_VLOCK_PLUGIN)) +#define IS_VLOCK_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\ + TYPE_VLOCK_PLUGIN)) +#define VLOCK_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),\ + TYPE_VLOCK_PLUGIN,\ + VlockPluginClass)) typedef struct _VlockPlugin VlockPlugin; typedef struct _VlockPluginClass VlockPluginClass; @@ -79,5 +86,6 @@ GType vlock_plugin_get_type(void); /* Open the plugin. */ bool vlock_plugin_open(VlockPlugin *self, GError **error); -GList *vlock_plugin_get_dependencies(VlockPlugin *self, const gchar *dependency_name); +GList *vlock_plugin_get_dependencies(VlockPlugin *self, + const gchar *dependency_name); bool vlock_plugin_call_hook(VlockPlugin *self, const gchar *hook_name); diff --git a/src/plugins.c b/src/plugins.c index efd7923..9c76549 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -115,7 +115,9 @@ static gint plugin_name_compare(VlockPlugin *p, const char *name) static VlockPlugin *get_plugin(const char *name) { - GList *item = g_list_find_custom(plugins, name, (GCompareFunc) plugin_name_compare); + GList *item = g_list_find_custom(plugins, + name, + (GCompareFunc) plugin_name_compare); if (item != NULL) return item->data; @@ -138,8 +140,8 @@ static VlockPlugin *__load_plugin(const char *name, GError **error) for (size_t i = 0; plugin_types[i] != 0; i++) { if (err == NULL || g_error_matches(err, - VLOCK_PLUGIN_ERROR, - VLOCK_PLUGIN_ERROR_NOT_FOUND)) + VLOCK_PLUGIN_ERROR, + VLOCK_PLUGIN_ERROR_NOT_FOUND)) /* Continue if the was no previous error or the error was "not found". */ g_clear_error(&err); else @@ -184,22 +186,22 @@ static bool __resolve_depedencies(GError **error) * that are required by the plugins loaded here because they are appended to * the end of the list. */ for (GList *plugin_item = plugins; - plugin_item != NULL; - plugin_item = g_list_next(plugin_item)) { + plugin_item != NULL; + plugin_item = g_list_next(plugin_item)) { VlockPlugin *p = plugin_item->data; for (GList *dependency_item = p->dependencies[REQUIRES]; - dependency_item != NULL; - dependency_item = g_list_next(dependency_item)) { + dependency_item != NULL; + dependency_item = g_list_next(dependency_item)) { const char *d = dependency_item->data; VlockPlugin *q = __load_plugin(d, NULL); if (q == NULL) { g_set_error( - error, - VLOCK_PLUGIN_ERROR, - VLOCK_PLUGIN_ERROR_DEPENDENCY, - "'%s' requires '%s' which could not be loaded", p->name, d); + error, + VLOCK_PLUGIN_ERROR, + VLOCK_PLUGIN_ERROR_DEPENDENCY, + "'%s' requires '%s' which could not be loaded", p->name, d); g_list_free(required_plugins); return false; } @@ -210,22 +212,22 @@ static bool __resolve_depedencies(GError **error) /* Fail if a plugins that is needed is not loaded. */ for (GList *plugin_item = plugins; - plugin_item != NULL; - plugin_item = g_list_next(plugin_item)) { + plugin_item != NULL; + plugin_item = g_list_next(plugin_item)) { VlockPlugin *p = plugin_item->data; for (GList *dependency_item = p->dependencies[NEEDS]; - dependency_item != NULL; - dependency_item = g_list_next(dependency_item)) { + dependency_item != NULL; + dependency_item = g_list_next(dependency_item)) { const char *d = dependency_item->data; VlockPlugin *q = get_plugin(d); if (q == NULL) { g_set_error( - error, - VLOCK_PLUGIN_ERROR, - VLOCK_PLUGIN_ERROR_DEPENDENCY, - "'%s' needs '%s' which is not loaded", p->name, d); + error, + VLOCK_PLUGIN_ERROR, + VLOCK_PLUGIN_ERROR_DEPENDENCY, + "'%s' needs '%s' which is not loaded", p->name, d); g_list_free(required_plugins); errno = 0; return false; @@ -238,13 +240,13 @@ static bool __resolve_depedencies(GError **error) /* Unload plugins whose prerequisites are not present, fail if those plugins * are required. */ for (GList *plugin_item = plugins; - plugin_item != NULL; ) { + plugin_item != NULL; ) { VlockPlugin *p = plugin_item->data; bool dependencies_loaded = true; for (GList *dependency_item = p->dependencies[DEPENDS]; - dependency_item != NULL; - dependency_item = g_list_next(dependency_item)) { + dependency_item != NULL; + dependency_item = g_list_next(dependency_item)) { const char *d = dependency_item->data; VlockPlugin *q = get_plugin(d); @@ -254,12 +256,12 @@ static bool __resolve_depedencies(GError **error) /* Abort if dependencies not met and plugin is required. */ if (g_list_find(required_plugins, p) != NULL) { g_set_error( - error, - VLOCK_PLUGIN_ERROR, - VLOCK_PLUGIN_ERROR_DEPENDENCY, - "'%s' is required by some other plugin but depends on '%s' which is not loaded", - p->name, - d); + error, + VLOCK_PLUGIN_ERROR, + VLOCK_PLUGIN_ERROR_DEPENDENCY, + "'%s' is required by some other plugin but depends on '%s' which is not loaded", + p->name, + d); g_list_free(required_plugins); errno = 0; return false; @@ -283,22 +285,22 @@ static bool __resolve_depedencies(GError **error) /* Fail if conflicting plugins are loaded. */ for (GList *plugin_item = plugins; - plugin_item != NULL; - plugin_item = g_list_next(plugin_item)) { + plugin_item != NULL; + plugin_item = g_list_next(plugin_item)) { VlockPlugin *p = plugin_item->data; for (GList *dependency_item = p->dependencies[CONFLICTS]; - dependency_item != NULL; - dependency_item = g_list_next(dependency_item)) { + dependency_item != NULL; + dependency_item = g_list_next(dependency_item)) { const char *d = dependency_item->data; if (get_plugin(d) != NULL) { g_set_error( - error, - VLOCK_PLUGIN_ERROR, - VLOCK_PLUGIN_ERROR_DEPENDENCY, - "'%s' and '%s' cannot be loaded at the same time", - p->name, - d); + error, + VLOCK_PLUGIN_ERROR, + VLOCK_PLUGIN_ERROR_DEPENDENCY, + "'%s' and '%s' cannot be loaded at the same time", + p->name, + d); errno = 0; return false; } @@ -311,7 +313,7 @@ static bool __resolve_depedencies(GError **error) static GList *get_edges(void); /* Sort the list of plugins according to their "preceeds" and "succeeds" - * dependencies. Fails if sorting is not possible because of circles. */ +* dependencies. Fails if sorting is not possible because of circles. */ static bool sort_plugins(GError **error) { GList *edges = get_edges(); @@ -343,16 +345,19 @@ static bool sort_plugins(GError **error) VlockPlugin *p = e->predecessor; VlockPlugin *s = e->successor; - g_string_append_printf(error_message, "\n\t'%s'\tmust come before\t'%s'", p->name, s->name); + g_string_append_printf(error_message, + "\n\t'%s'\tmust come before\t'%s'", + p->name, + s->name); g_free(e); edges = g_list_delete_link(edges, edges); } g_set_error(error, - VLOCK_PLUGIN_ERROR, - VLOCK_PLUGIN_ERROR_DEPENDENCY, - "%s", - error_message->str); + VLOCK_PLUGIN_ERROR, + VLOCK_PLUGIN_ERROR_DEPENDENCY, + "%s", + error_message->str); g_string_free(error_message, true); return false; @@ -366,13 +371,13 @@ static GList *get_edges(void) GList *edges = NULL; for (GList *plugin_item = plugins; - plugin_item != NULL; - plugin_item = g_list_next(plugin_item)) { + plugin_item != NULL; + plugin_item = g_list_next(plugin_item)) { VlockPlugin *p = plugin_item->data; /* p must come after these */ for (GList *predecessor_item = p->dependencies[SUCCEEDS]; - predecessor_item != NULL; - predecessor_item = g_list_next(predecessor_item)) { + predecessor_item != NULL; + predecessor_item = g_list_next(predecessor_item)) { VlockPlugin *q = get_plugin(predecessor_item->data); if (q != NULL) @@ -381,8 +386,8 @@ static GList *get_edges(void) /* p must come before these */ for (GList *successor_item = p->dependencies[PRECEEDS]; - successor_item != NULL; - successor_item = g_list_next(successor_item)) { + successor_item != NULL; + successor_item = g_list_next(successor_item)) { VlockPlugin *q = get_plugin(successor_item->data); if (q != NULL) @@ -403,22 +408,23 @@ static GList *get_edges(void) void handle_vlock_start(const char *hook_name) { for (GList *plugin_item = plugins; - plugin_item != NULL; - plugin_item = g_list_next(plugin_item)) { + plugin_item != NULL; + plugin_item = g_list_next(plugin_item)) { VlockPlugin *p = plugin_item->data; if (!vlock_plugin_call_hook(p, hook_name)) { int errsv = errno; for (GList *reverse_item = g_list_previous(plugin_item); - reverse_item != NULL; - reverse_item = g_list_previous(reverse_item)) { + reverse_item != NULL; + reverse_item = g_list_previous(reverse_item)) { VlockPlugin *r = reverse_item->data; (void) vlock_plugin_call_hook(r, "vlock_end"); } if (errsv) - fprintf(stderr, "vlock: plugin '%s' failed: %s\n", p->name, strerror(errsv)); + fprintf(stderr, "vlock: plugin '%s' failed: %s\n", p->name, + strerror(errsv)); exit(EXIT_FAILURE); } @@ -429,8 +435,8 @@ void handle_vlock_start(const char *hook_name) void handle_vlock_end(const char *hook_name) { for (GList *plugin_item = g_list_last(plugins); - plugin_item != NULL; - plugin_item = g_list_previous(plugin_item)) { + plugin_item != NULL; + plugin_item = g_list_previous(plugin_item)) { VlockPlugin *p = plugin_item->data; (void) vlock_plugin_call_hook(p, hook_name); } @@ -442,8 +448,8 @@ void handle_vlock_end(const char *hook_name) void handle_vlock_save(const char *hook_name) { for (GList *plugin_item = plugins; - plugin_item != NULL; - plugin_item = g_list_next(plugin_item)) { + plugin_item != NULL; + plugin_item = g_list_next(plugin_item)) { VlockPlugin *p = plugin_item->data; if (p->save_disabled) @@ -462,8 +468,8 @@ void handle_vlock_save(const char *hook_name) void handle_vlock_save_abort(const char *hook_name) { for (GList *plugin_item = g_list_last(plugins); - plugin_item != NULL; - plugin_item = g_list_previous(plugin_item)) { + plugin_item != NULL; + plugin_item = g_list_previous(plugin_item)) { VlockPlugin *p = plugin_item->data; if (p->save_disabled) @@ -473,3 +479,4 @@ void handle_vlock_save_abort(const char *hook_name) p->save_disabled = true; } } + diff --git a/src/process.c b/src/process.c index 78fb012..775f979 100644 --- a/src/process.c +++ b/src/process.c @@ -28,7 +28,6 @@ GQuark vlock_process_error_quark(void) return g_quark_from_static_string("vlock-process-error-quark"); } - /* Do nothing. */ static void ignore_sigalarm(int __attribute__((unused)) signum) { @@ -155,38 +154,35 @@ bool create_child(struct child_process *child, GError **error) (void) fcntl(status_pipe[1], F_SETFD, FD_CLOEXEC); - if (child->stdin_fd == REDIRECT_PIPE) { + if (child->stdin_fd == REDIRECT_PIPE) if (pipe(stdin_pipe) < 0) { g_set_error(error, - VLOCK_PROCESS_ERROR, - VLOCK_PROCESS_ERROR_FAILED, - "could not open stdin pipe: %s", - g_strerror(errno)); + VLOCK_PROCESS_ERROR, + VLOCK_PROCESS_ERROR_FAILED, + "could not open stdin pipe: %s", + g_strerror(errno)); goto stdin_pipe_failed; } - } - if (child->stdout_fd == REDIRECT_PIPE) { + if (child->stdout_fd == REDIRECT_PIPE) if (pipe(stdout_pipe) < 0) { g_set_error(error, - VLOCK_PROCESS_ERROR, - VLOCK_PROCESS_ERROR_FAILED, - "could not open stdout pipe: %s", - g_strerror(errno)); + VLOCK_PROCESS_ERROR, + VLOCK_PROCESS_ERROR_FAILED, + "could not open stdout pipe: %s", + g_strerror(errno)); goto stdout_pipe_failed; } - } - if (child->stderr_fd == REDIRECT_PIPE) { + if (child->stderr_fd == REDIRECT_PIPE) if (pipe(stderr_pipe) < 0) { g_set_error(error, - VLOCK_PROCESS_ERROR, - VLOCK_PROCESS_ERROR_FAILED, - "could not open stderr pipe: %s", - g_strerror(errno)); + VLOCK_PROCESS_ERROR, + VLOCK_PROCESS_ERROR_FAILED, + "could not open stderr pipe: %s", + g_strerror(errno)); goto stderr_pipe_failed; } - } child->pid = fork(); @@ -230,7 +226,7 @@ bool create_child(struct child_process *child, GError **error) (void) close(status_pipe[1]); _exit(child->function(child->argument)); } else { - execv(child->path, (char *const*)child->argv); + execv(child->path, (char *const*) child->argv); (void) write(status_pipe[1], &errno, sizeof errno); } @@ -239,24 +235,25 @@ bool create_child(struct child_process *child, GError **error) if (child->pid < 0) { g_set_error(error, - VLOCK_PROCESS_ERROR, - VLOCK_PROCESS_ERROR_FAILED, - "could not fork: %s", - g_strerror(errno)); + VLOCK_PROCESS_ERROR, + VLOCK_PROCESS_ERROR_FAILED, + "could not fork: %s", + g_strerror(errno)); goto fork_failed; } (void) close(status_pipe[1]); /* Get the error status from the child, if any. */ - if (read(status_pipe[0], &child_errno, sizeof child_errno) == sizeof child_errno) { + if (read(status_pipe[0], &child_errno, + sizeof child_errno) == sizeof child_errno) { g_set_error(error, - VLOCK_PROCESS_ERROR, - child_errno == ENOENT ? - VLOCK_PROCESS_ERROR_NOT_FOUND : - VLOCK_PROCESS_ERROR_FAILED, - "child process could not exec: %s", - g_strerror(child_errno)); + VLOCK_PROCESS_ERROR, + child_errno == ENOENT ? + VLOCK_PROCESS_ERROR_NOT_FOUND : + VLOCK_PROCESS_ERROR_FAILED, + "child process could not exec: %s", + g_strerror(child_errno)); goto child_failed; } @@ -310,3 +307,4 @@ stdin_pipe_failed: return false; } + diff --git a/src/process.h b/src/process.h index a62a4a9..9c20ab3 100644 --- a/src/process.h +++ b/src/process.h @@ -38,7 +38,8 @@ void ensure_death(pid_t pid); #define REDIRECT_DEV_NULL (-3) #define REDIRECT_PIPE (-4) -struct child_process { +struct child_process +{ /* Function that will be run in the child. */ int (*function)(void *argument); /* Argument for the function. */ diff --git a/src/prompt.c b/src/prompt.c index 7b092ce..be8e27c 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -104,10 +104,10 @@ before_select: if (timeout_val == NULL) { g_propagate_error(error, - g_error_new_literal( - VLOCK_PROMPT_ERROR, - VLOCK_PROMPT_ERROR_FAILED, - g_strerror(errno))); + g_error_new_literal( + VLOCK_PROMPT_ERROR, + VLOCK_PROMPT_ERROR_FAILED, + g_strerror(errno))); return NULL; } @@ -123,8 +123,8 @@ before_select: switch (errno) { case 0: g_propagate_error(error, - g_error_new_literal( - VLOCK_PROMPT_ERROR, VLOCK_PROMPT_ERROR_TIMEOUT, "")); + g_error_new_literal( + VLOCK_PROMPT_ERROR, VLOCK_PROMPT_ERROR_TIMEOUT, "")); goto out; case EINTR: /* A signal was caught. Restart. */ @@ -132,10 +132,10 @@ before_select: goto before_select; default: g_propagate_error(error, - g_error_new_literal( - VLOCK_PROMPT_ERROR, - VLOCK_PROMPT_ERROR_FAILED, - g_strerror(errno))); + g_error_new_literal( + VLOCK_PROMPT_ERROR, + VLOCK_PROMPT_ERROR_FAILED, + g_strerror(errno))); goto out; } } @@ -159,10 +159,10 @@ before_select: /* Copy the string. */ if ((result = strdup(buffer)) == NULL) g_propagate_error(error, - g_error_new_literal( - VLOCK_PROMPT_ERROR, - VLOCK_PROMPT_ERROR_FAILED, - g_strerror(errno))); + g_error_new_literal( + VLOCK_PROMPT_ERROR, + VLOCK_PROMPT_ERROR_FAILED, + g_strerror(errno))); /* Clear our buffer. */ memset(buffer, 0, sizeof buffer); @@ -178,7 +178,9 @@ out: } /* Same as prompt except that the characters entered are not echoed. */ -char *prompt_echo_off(const char *msg, const struct timespec *timeout, GError **error) +char *prompt_echo_off(const char *msg, + const struct timespec *timeout, + GError **error) { struct termios term; tcflag_t lflag; diff --git a/src/prompt.h b/src/prompt.h index 3df0f05..ce760d7 100644 --- a/src/prompt.h +++ b/src/prompt.h @@ -59,7 +59,9 @@ enum { char *prompt(const char *msg, const struct timespec *timeout, GError **error); /* Same as prompt() above, except that characters entered are not echoed. */ -char *prompt_echo_off(const char *msg, const struct timespec *timeout, GError **error); +char *prompt_echo_off(const char *msg, + const struct timespec *timeout, + GError **error); /* Read a single character from the stdin. If the timeout is reached * 0 is returned. */ diff --git a/src/script.c b/src/script.c index 43bd275..698891d 100644 --- a/src/script.c +++ b/src/script.c @@ -51,26 +51,27 @@ #include "plugin.h" #include "script.h" -static char *read_dependency(const char *path, const char *dependency_name, GError **error); +static char *read_dependency(const char *path, + const char *dependency_name, + GError **error); static void parse_dependency(char *data, GList **dependency_list); /* Get the dependency from the script. */ static bool get_dependency(const char *path, const char *dependency_name, - GList **dependency_list, GError **error) + GList **dependency_list, GError **error) { GError *tmp_error = NULL; /* Read the dependency data. */ char *data = read_dependency(path, dependency_name, &tmp_error); - if (data == NULL) { + if (data == NULL) { if (tmp_error != NULL) { g_propagate_error(error, tmp_error); return false; - } else { + } else /* No data. */ return true; - } } /* Parse the dependency data into the list. */ @@ -84,7 +85,9 @@ static bool get_dependency(const char *path, const char *dependency_name, /* Read the dependency data by starting the script with the name of the * dependency as a single command line argument. The script should then print * the dependencies to its stdout one on per line. */ -static char *read_dependency(const char *path, const char *dependency_name, GError **error) +static char *read_dependency(const char *path, + const char *dependency_name, + GError **error) { GError *tmp_error = NULL; const char *argv[] = { path, dependency_name, NULL }; @@ -127,12 +130,12 @@ static char *read_dependency(const char *path, const char *dependency_name, GErr if (select(child.stdout_fd+1, &read_fds, NULL, NULL, &t) != 1) { timeout: g_set_error(&tmp_error, - VLOCK_PLUGIN_ERROR, - VLOCK_PLUGIN_ERROR_FAILED, - "reading dependency (%s) data from script %s failed: timeout", - dependency_name, - /* XXX: plugin->name */ path - ); + VLOCK_PLUGIN_ERROR, + VLOCK_PLUGIN_ERROR_FAILED, + "reading dependency (%s) data from script %s failed: timeout", + dependency_name, + /* XXX: plugin->name */ path + ); goto error; } @@ -157,12 +160,13 @@ timeout: break; if (data_length+length+1 > LINE_MAX) { - g_set_error(&tmp_error, - VLOCK_PLUGIN_ERROR, - VLOCK_PLUGIN_ERROR_FAILED, - "reading dependency (%s) data from script %s failed: too much data", - dependency_name, - /* XXX: plugin->name */ path + g_set_error( + &tmp_error, + VLOCK_PLUGIN_ERROR, + VLOCK_PLUGIN_ERROR_FAILED, + "reading dependency (%s) data from script %s failed: too much data", + dependency_name, + /* XXX: plugin->name */ path ); goto error; } @@ -200,16 +204,18 @@ static void parse_dependency(char *data, GList **dependency_list) for (size_t i = 0; dependency_items[i] != NULL; i++) *dependency_list = g_list_append( - *dependency_list, - g_strdup(dependency_items[i]) - ); + *dependency_list, + g_strdup(dependency_items[i]) + ); g_strfreev(dependency_items); } G_DEFINE_TYPE(VlockScript, vlock_script, TYPE_VLOCK_PLUGIN) -#define VLOCK_SCRIPT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), TYPE_VLOCK_SCRIPT, VlockScriptPrivate)) +#define VLOCK_SCRIPT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj),\ + TYPE_VLOCK_SCRIPT,\ + VlockScriptPrivate)) struct _VlockScriptPrivate { @@ -263,16 +269,16 @@ static bool vlock_script_open(VlockPlugin *plugin, GError **error) /* Get the dependency information. Whether the script is executable or not * is also detected here. */ for (size_t i = 0; i < nr_dependencies; i++) - if (!get_dependency(self->priv->path, dependency_names[i], &plugin->dependencies[i], &tmp_error)) { + if (!get_dependency(self->priv->path, dependency_names[i], + &plugin->dependencies[i], &tmp_error)) { if (g_error_matches(tmp_error, - VLOCK_PROCESS_ERROR, - VLOCK_PROCESS_ERROR_NOT_FOUND) && i == 0) { + VLOCK_PROCESS_ERROR, + VLOCK_PROCESS_ERROR_NOT_FOUND) && i == 0) { g_set_error(error, VLOCK_PLUGIN_ERROR, VLOCK_PLUGIN_ERROR_NOT_FOUND, - "%s", tmp_error->message); + "%s", tmp_error->message); g_clear_error(&tmp_error); - } else { + } else g_propagate_error(error, tmp_error); - } return false; } @@ -348,7 +354,7 @@ static bool vlock_script_call_hook(VlockPlugin *plugin, const gchar *hook_name) length = write(self->priv->fd, hook_name, hook_name_length); if (length > 0) - length += write(self->priv->fd, &newline, sizeof newline); + length += write(self->priv->fd, &newline, sizeof newline); /* Restore the previous SIGPIPE handler. */ (void) sigaction(SIGPIPE, &oldact, NULL); @@ -359,7 +365,6 @@ static bool vlock_script_call_hook(VlockPlugin *plugin, const gchar *hook_name) return !self->priv->dead; } - /* Initialize script class. */ static void vlock_script_class_init(VlockScriptClass *klass) { @@ -374,3 +379,4 @@ static void vlock_script_class_init(VlockScriptClass *klass) plugin_class->open = vlock_script_open; plugin_class->call_hook = vlock_script_call_hook; } + diff --git a/src/script.h b/src/script.h index 135bed8..fc3902d 100644 --- a/src/script.h +++ b/src/script.h @@ -6,11 +6,18 @@ * Script type macros. */ #define TYPE_VLOCK_SCRIPT (vlock_script_get_type()) -#define VLOCK_SCRIPT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_VLOCK_SCRIPT, VlockScript)) -#define VLOCK_SCRIPT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_VLOCK_SCRIPT, VlockScriptClass)) -#define IS_VLOCK_SCRIPT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_VLOCK_SCRIPT)) -#define IS_VLOCK_SCRIPT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_VLOCK_SCRIPT)) -#define VLOCK_SCRIPT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_VLOCK_SCRIPT, VlockScriptClass)) +#define VLOCK_SCRIPT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_VLOCK_SCRIPT,\ + VlockScript)) +#define VLOCK_SCRIPT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\ + TYPE_VLOCK_SCRIPT,\ + VlockScriptClass)) +#define IS_VLOCK_SCRIPT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\ + TYPE_VLOCK_SCRIPT)) +#define IS_VLOCK_SCRIPT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\ + TYPE_VLOCK_SCRIPT)) +#define VLOCK_SCRIPT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),\ + TYPE_VLOCK_SCRIPT,\ + VlockScriptClass)) typedef struct _VlockScript VlockScript; typedef struct _VlockScriptClass VlockScriptClass; diff --git a/src/signals.c b/src/signals.c index c69502c..4cf8225 100644 --- a/src/signals.c +++ b/src/signals.c @@ -10,26 +10,27 @@ static const char *termination_blurb = // XXX: reformat, bullet points etc. -"\n" -"vlock caught a signal and will now terminate.\n" -"It is very likely that the reason for this\n" -"is an error in the program. If you believe\n" -"this to be the case please send and email to\n" -"the author. Please include as much information\n" -"as possible about your system and the circum-\n" -"stances that led to the problem. Do not forget\n" -"to mention the version number of vlock. Please\n" -"include the word \"vlock\" in the subject of\n" -"your email.\n" -"\n" -"Frank Benkstein \n" -"\n" + "\n" + "vlock caught a signal and will now terminate.\n" + "It is very likely that the reason for this\n" + "is an error in the program. If you believe\n" + "this to be the case please send and email to\n" + "the author. Please include as much information\n" + "as possible about your system and the circum-\n" + "stances that led to the problem. Do not forget\n" + "to mention the version number of vlock. Please\n" + "include the word \"vlock\" in the subject of\n" + "your email.\n" + "\n" + "Frank Benkstein \n" + "\n" ; static void terminate(int signum) { vlock_invoke_atexit(); - fprintf(stderr, "vlock: Killed by signal %d (%s)!\n", signum, strsignal(signum)); + fprintf(stderr, "vlock: Killed by signal %d (%s)!\n", signum, + strsignal(signum)); fputs(termination_blurb, stderr); raise(signum); } @@ -56,3 +57,4 @@ void install_signal_handlers(void) (void) sigaction(SIGABRT, &sa, NULL); (void) sigaction(SIGSEGV, &sa, NULL); } + diff --git a/src/terminal.c b/src/terminal.c index e2c3edc..682a18d 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -21,3 +21,4 @@ void restore_terminal(void) term.c_lflag = lflag; (void) tcsetattr(STDIN_FILENO, TCSANOW, &term); } + diff --git a/src/tsort.c b/src/tsort.c index c00bd41..834d951 100644 --- a/src/tsort.c +++ b/src/tsort.c @@ -23,8 +23,8 @@ static GList *get_zeros(GList *nodes, GList *edges) GList *zeros = g_list_copy(nodes); for (GList *edge_item = edges; - edge_item != NULL; - edge_item = g_list_next(edge_item)) { + edge_item != NULL; + edge_item = g_list_next(edge_item)) { struct edge *e = edge_item->data; zeros = g_list_remove(zeros, e->successor); } @@ -36,8 +36,8 @@ static GList *get_zeros(GList *nodes, GList *edges) static bool is_zero(void *node, GList *edges) { for (GList *edge_item = edges; - edge_item != NULL; - edge_item = g_list_next(edge_item)) { + edge_item != NULL; + edge_item = g_list_next(edge_item)) { struct edge *e = edge_item->data; if (e->successor == node) @@ -76,7 +76,7 @@ GList *tsort(GList *nodes, GList **edges) /* Then look at each edge ... */ for (GList *edge_item = *edges; - edge_item != NULL;) { + edge_item != NULL;) { struct edge *e = edge_item->data; GList *tmp = g_list_next(edge_item); @@ -106,5 +106,7 @@ GList *tsort(GList *nodes, GList **edges) g_list_free(zeros); - return sorted_nodes;; + return sorted_nodes; + ; } + diff --git a/src/tsort.h b/src/tsort.h index 6b43bb0..c30e090 100644 --- a/src/tsort.h +++ b/src/tsort.h @@ -16,7 +16,8 @@ /* An edge of the graph, specifying that predecessor must come before * successor. */ -struct edge { +struct edge +{ void *predecessor; void *successor; }; diff --git a/src/util.c b/src/util.c index 0d2b307..73f35ad 100644 --- a/src/util.c +++ b/src/util.c @@ -31,9 +31,9 @@ * is returned, too. "0" is also parsed as NULL. */ struct timespec *parse_seconds(const char *s) { - if (s == NULL) { + if (s == NULL) return NULL; - } else { + else { char *n; struct timespec *t = calloc(sizeof *t, 1); @@ -58,7 +58,7 @@ void vlock_invoke_atexit(void) while (atexit_functions != NULL) { (*(void (**)())&atexit_functions->data)(); atexit_functions = g_list_delete_link(atexit_functions, - atexit_functions); + atexit_functions); } } @@ -68,5 +68,6 @@ void vlock_atexit(void (*function)(void)) atexit(vlock_invoke_atexit); atexit_functions = g_list_prepend(atexit_functions, - *(void **)&function); + *(void **) &function); } + diff --git a/src/vlock-main.c b/src/vlock-main.c index fb69936..6e7dcfe 100644 --- a/src/vlock-main.c +++ b/src/vlock-main.c @@ -54,8 +54,8 @@ static void auth_loop(const char *username) #ifndef NO_ROOT_PASS if (strcmp(username, "root") == 0) #endif - /* ... do not fall back to "root". */ - auth_names[1] = NULL; + /* ... do not fall back to "root". */ + auth_names[1] = NULL; /* Get the vlock message from the environment. */ vlock_message = getenv("VLOCK_MESSAGE"); @@ -110,21 +110,31 @@ static void auth_loop(const char *username) g_assert(err != NULL); if (g_error_matches(err, - VLOCK_PROMPT_ERROR, - VLOCK_PROMPT_ERROR_TIMEOUT)) { + VLOCK_PROMPT_ERROR, + VLOCK_PROMPT_ERROR_TIMEOUT)) fprintf(stderr, "Timeout!\n"); - } else { + else { fprintf(stderr, "vlock: %s\n", err->message); if (g_error_matches(err, - VLOCK_AUTH_ERROR, - VLOCK_AUTH_ERROR_FAILED)) { + VLOCK_AUTH_ERROR, + VLOCK_AUTH_ERROR_FAILED)) { fputc('\n', stderr); - fprintf(stderr, "******************************************************************\n"); - fprintf(stderr, "*** You may not be able to able to unlock your terminal now. ***\n"); - fprintf(stderr, "*** ***\n"); - fprintf(stderr, "*** Log into another terminal and kill the vlock-main process. ***\n"); - fprintf(stderr, "******************************************************************\n"); + fprintf( + stderr, + "******************************************************************\n"); + fprintf( + stderr, + "*** You may not be able to able to unlock your terminal now. ***\n"); + fprintf( + stderr, + "*** ***\n"); + fprintf( + stderr, + "*** Log into another terminal and kill the vlock-main process. ***\n"); + fprintf( + stderr, + "******************************************************************\n"); fputc('\n', stderr); sleep(3); } @@ -146,7 +156,10 @@ auth_success: void display_auth_tries(void) { if (auth_tries > 0) - fprintf(stderr, "%d failed authentication %s.\n", auth_tries, auth_tries > 1 ? "tries" : "try"); + fprintf(stderr, + "%d failed authentication %s.\n", + auth_tries, + auth_tries > 1 ? "tries" : "try"); } #ifdef USE_PLUGINS @@ -154,6 +167,7 @@ static void call_end_hook(void) { (void) plugin_hook("vlock_end"); } + #endif /* Lock the current terminal until proper authentication is received. */ @@ -187,12 +201,14 @@ int main(int argc, char *const argv[]) g_assert(tmp_error != NULL); if (g_error_matches(tmp_error, - VLOCK_PLUGIN_ERROR, - VLOCK_PLUGIN_ERROR_NOT_FOUND)) { + VLOCK_PLUGIN_ERROR, + VLOCK_PLUGIN_ERROR_NOT_FOUND)) g_fprintf(stderr, "vlock: no such plugin '%s'\n", argv[i]); - } else { - g_fprintf(stderr, "vlock: loading plugin '%s' failed: %s\n", argv[i], tmp_error->message); - } + else + g_fprintf(stderr, + "vlock: loading plugin '%s' failed: %s\n", + argv[i], + tmp_error->message); g_clear_error(&tmp_error); exit(EXIT_FAILURE); @@ -202,10 +218,12 @@ int main(int argc, char *const argv[]) vlock_atexit(unload_plugins); if (!resolve_dependencies(&tmp_error)) { - g_assert(tmp_error != NULL); - g_fprintf(stderr, "vlock: error resolving plugin dependencies: %s\n", tmp_error->message); - g_clear_error(&tmp_error); - exit(EXIT_FAILURE); + g_assert(tmp_error != NULL); + g_fprintf(stderr, + "vlock: error resolving plugin dependencies: %s\n", + tmp_error->message); + g_clear_error(&tmp_error); + exit(EXIT_FAILURE); } plugin_hook("vlock_start"); @@ -215,12 +233,14 @@ int main(int argc, char *const argv[]) if (argc == 2 && (strcmp(argv[1], "all") == 0)) { if (!lock_console_switch()) { if (errno) - g_fprintf(stderr, "vlock: could not disable console switching: %s\n", g_strerror(errno)); + g_fprintf(stderr, + "vlock: could not disable console switching: %s\n", + g_strerror(errno)); exit(EXIT_FAILURE); } - ensure_atexit((void (*)(void))unlock_console_switch); + ensure_atexit((void (*) (void))unlock_console_switch); } else if (argc > 1) { g_fprintf(stderr, "vlock: plugin support disabled\n"); exit(EXIT_FAILURE); @@ -241,3 +261,4 @@ int main(int argc, char *const argv[]) exit(EXIT_SUCCESS); } + -- 2.11.4.GIT