* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: David Zeuthen <davidz@redhat.com>
*/
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
+
+#include <glib/gstdio.h>
+
+#ifdef G_OS_UNIX
#include <unistd.h>
#endif
-#ifdef _WIN32
+#ifdef G_OS_WIN32
#include <io.h>
#endif
-#include <glib/gstdio.h>
-
#include "gdbusauthmechanismsha1.h"
#include "gcredentials.h"
#include "gdbuserror.h"
/* ---------------------------------------------------------------------------------------------------- */
-G_DEFINE_TYPE (GDBusAuthMechanismSha1, _g_dbus_auth_mechanism_sha1, G_TYPE_DBUS_AUTH_MECHANISM);
+G_DEFINE_TYPE_WITH_PRIVATE (GDBusAuthMechanismSha1, _g_dbus_auth_mechanism_sha1, G_TYPE_DBUS_AUTH_MECHANISM)
/* ---------------------------------------------------------------------------------------------------- */
GObjectClass *gobject_class;
GDBusAuthMechanismClass *mechanism_class;
- g_type_class_add_private (klass, sizeof (GDBusAuthMechanismSha1Private));
-
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = _g_dbus_auth_mechanism_sha1_finalize;
static void
_g_dbus_auth_mechanism_sha1_init (GDBusAuthMechanismSha1 *mechanism)
{
- mechanism->priv = G_TYPE_INSTANCE_GET_PRIVATE (mechanism,
- G_TYPE_DBUS_AUTH_MECHANISM_SHA1,
- GDBusAuthMechanismSha1Private);
+ mechanism->priv = _g_dbus_auth_mechanism_sha1_get_instance_private (mechanism);
}
/* ---------------------------------------------------------------------------------------------------- */
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
- _("Error statting directory `%s': %s"),
+ _("Error when getting information for directory '%s': %s"),
path,
strerror (errno));
g_free (path);
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("Permissions on directory `%s' are malformed. Expected mode 0700, got 0%o"),
+ _("Permissions on directory '%s' are malformed. Expected mode 0700, got 0%o"),
path,
statbuf.st_mode & 0777);
g_free (path);
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
- _("Error creating directory `%s': %s"),
+ _("Error creating directory '%s': %s"),
path,
strerror (errno));
g_free (path);
guint n;
gchar **lines;
- g_return_val_if_fail (cookie_context != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+ g_return_val_if_fail (cookie_context != NULL, NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
ret = NULL;
path = NULL;
error))
{
g_prefix_error (error,
- _("Error opening keyring `%s' for reading: "),
+ _("Error opening keyring '%s' for reading: "),
path);
goto out;
}
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("Line %d of the keyring at `%s' with content `%s' is malformed"),
+ _("Line %d of the keyring at '%s' with content '%s' is malformed"),
n + 1,
path,
line);
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("First token of line %d of the keyring at `%s' with content `%s' is malformed"),
+ _("First token of line %d of the keyring at '%s' with content '%s' is malformed"),
n + 1,
path,
line);
}
line_when = g_ascii_strtoll (tokens[1], &endp, 10);
+ line_when = line_when; /* To avoid -Wunused-but-set-variable */
if (*endp != '\0')
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("Second token of line %d of the keyring at `%s' with content `%s' is malformed"),
+ _("Second token of line %d of the keyring at '%s' with content '%s' is malformed"),
n + 1,
path,
line);
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("Didn't find cookie with id %d in the keyring at `%s'"),
+ _("Didn't find cookie with id %d in the keyring at '%s'"),
cookie_id,
path);
}
/* function for logging important events that the system administrator should take notice of */
+G_GNUC_PRINTF(1, 2)
static void
_log (const gchar *message,
...)
num_tries++;
if (num_tries == 50)
{
- /* ok, we slept 50*10ms = 0.5 seconds.. Conclude that the lock-file must be
+ /* ok, we slept 50*10ms = 0.5 seconds. Conclude that the lock file must be
* stale (nuke the it from orbit)
*/
if (g_unlink (lock) != 0)
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
- _("Error deleting stale lock-file `%s': %s"),
+ _("Error deleting stale lock file '%s': %s"),
lock,
strerror (errno));
goto out;
}
- _log ("Deleted stale lock-file `%s'", lock);
+ _log ("Deleted stale lock file '%s'", lock);
break;
}
}
goto again;
}
#endif
+ num_create_tries = num_create_tries; /* To avoid -Wunused-but-set-variable */
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
- _("Error creating lock-file `%s': %s"),
+ _("Error creating lock file '%s': %s"),
lock,
strerror (errno));
goto out;
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
- _("Error closing (unlinked) lock-file `%s': %s"),
+ _("Error closing (unlinked) lock file '%s': %s"),
lock,
strerror (errno));
goto out;
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
- _("Error unlinking lock-file `%s': %s"),
+ _("Error unlinking lock file '%s': %s"),
lock,
strerror (errno));
goto out;
lines = NULL;
new_contents = NULL;
have_id = FALSE;
+ use_id = 0;
use_cookie = NULL;
lock_fd = -1;
{
g_propagate_prefixed_error (error,
local_error,
- _("Error opening keyring `%s' for writing: "),
+ _("Error opening keyring '%s' for writing: "),
path);
goto out;
}
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("Line %d of the keyring at `%s' with content `%s' is malformed"),
+ _("Line %d of the keyring at '%s' with content '%s' is malformed"),
n + 1,
path,
line);
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("First token of line %d of the keyring at `%s' with content `%s' is malformed"),
+ _("First token of line %d of the keyring at '%s' with content '%s' is malformed"),
n + 1,
path,
line);
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("Second token of line %d of the keyring at `%s' with content `%s' is malformed"),
+ _("Second token of line %d of the keyring at '%s' with content '%s' is malformed"),
n + 1,
path,
line);
g_strfreev (tokens);
goto out;
}
+ line_when = line_when; /* To avoid -Wunused-but-set-variable */
+
/* D-Bus spec says:
*
else
{
g_prefix_error (error,
- _("(Additionally, releasing the lock for `%s' also failed: %s) "),
+ _("(Additionally, releasing the lock for '%s' also failed: %s) "),
path,
local_error->message);
}
tokens = g_strsplit (data, " ", 0);
if (g_strv_length (tokens) != 2)
{
- g_warning ("Malformed data `%s'", data);
+ g_warning ("Malformed data '%s'", data);
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
goto out;
}
/* TODO: use GDBusAuthObserver here to get the cookie context to use? */
cookie_context = "org_gtk_gdbus_general";
+ cookie_id = -1;
error = NULL;
if (!keyring_generate_entry (cookie_context,
&cookie_id,
tokens = g_strsplit (data, " ", 0);
if (g_strv_length (tokens) != 3)
{
- g_warning ("Malformed data `%s'", data);
+ g_warning ("Malformed data '%s'", data);
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
goto out;
}
cookie_id = g_ascii_strtoll (tokens[1], &endp, 10);
if (*endp != '\0')
{
- g_warning ("Malformed cookie_id `%s'", tokens[1]);
+ g_warning ("Malformed cookie_id '%s'", tokens[1]);
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
goto out;
}