]> saetta.ns0.it Git - libzakcgi/commitdiff
Conflict on merge branch 'develop' into form_libzakform form_libzakform
authorAndrea Zagli <azagli@libero.it>
Sat, 21 May 2016 07:20:36 +0000 (09:20 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 21 May 2016 07:20:36 +0000 (09:20 +0200)
1  2 
src/session.c

diff --cc src/session.c
index 7d9d3f490fc0e0527179ee726fb75bad0068192b,87391d4ec393eb144e791ca215b461432cd45daf..aa8d0bc3c89c31b0b61452d030552d4bb405423f
        #include <config.h>
  #endif
  
 +#include <stdlib.h>
 +
+ #include <sys/stat.h>
+ #include <syslog.h>
++
+ #include <glib/gstdio.h>
  #include <gio/gio.h>
  
  #include <string.h>
@@@ -126,7 -124,10 +131,8 @@@ ZakCgiSessio
                                                          const gchar *path,
                                                          gint minutes)
  {
 -      GHashTable *ht_cookies;
 -
        GDateTime *gdt_now;
+       GDateTime *gdt_exp;
  
        ZakCgiSession *zak_cgi_session;
        ZakCgiSessionPrivate *priv;
@@@ -248,49 -253,11 +259,50 @@@ zak_cgi_session_set_value_full (ZakCgiS
  {
        ZakCgiSessionPrivate *priv = ZAK_CGI_SESSION_GET_PRIVATE (session);
  
 +      GError *error;
 +
        if (priv->kfile != NULL)
                {
 -                      g_key_file_set_string (priv->kfile, "SESSION", name, value);
 -                      g_key_file_save_to_file (priv->kfile, g_file_get_path (priv->gfile), NULL);
 +                      if (name == NULL)
 +                              {
 +                                      error = NULL;
 +                                      if (!g_key_file_remove_group (priv->kfile, group, &error)
 +                                              || error != NULL)
 +                                              {
 +                                                      g_warning ("Unable to unset key «%s» in group «%s»: %s.",
 +                                                                         name,
 +                                                                         group,
 +                                                                         error != NULL && error->message != NULL ? error->message : "no details");
 +                                              }
 +                              }
 +                      else
 +                              {
 +                                      if (value == NULL)
 +                                              {
 +                                                      error = NULL;
 +                                                      if (!g_key_file_remove_key (priv->kfile, group, name, &error)
 +                                                              || error != NULL)
 +                                                              {
 +                                                                      g_warning ("Unable to unset key «%s» in group «%s»: %s.",
 +                                                                                         name,
 +                                                                                         group,
 +                                                                                         error != NULL && error->message != NULL ? error->message : "no details");
 +                                                              }
 +                                              }
 +                                      else
 +                                              {
 +                                                      g_key_file_set_string (priv->kfile, group, name, value);
 +                                              }
 +                              }
 +
 +                      error = NULL;
 +                      if (!g_key_file_save_to_file (priv->kfile, g_file_get_path (priv->gfile), &error)
 +                              || error != NULL)
 +                              {
 +                                      g_warning ("Unable to write session file: %s.",
 +                                                         error != NULL && error->message != NULL ? error->message : "no details");
 +                              }
+                       g_chmod (g_file_get_path (priv->gfile), S_IRUSR | S_IWUSR);
                }
  }