[OTR-dev] pidgin-otr: mode 600 instead of 644

Caspar Clemens Mierau damokles at ubuntu.com
Tue Jun 17 17:17:14 EDT 2008

> > Actually I even think that you are already fine using g_fopen under
> > Win32, but somebody needs to confirm this.
> But there's no equivalent for umask, right?

Right. On Windows there is POSIX umask equivalent. There only exists a
readonly flag which poorly acts like a 444 mode. Glib therefore mostly
seems to ignore umask calls and only tries to set "readonly" when it
seems equivalent to the current umask.

If we want to be totally safe, we should check the platform and don't
call the umask when on Win32. Otherwise trusting glib documentation
actually prevents us from writing more code than actually necessary.

Let's have a look at g_chmod in glib:

 * g_chmod:
 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
 * @mode: as in chmod()
 * A wrapper for the POSIX chmod() function. The chmod() function is
 * used to set the permissions of a file system object. Note that on
 * Windows the file protection mechanism is not at all POSIX-like, and
 * the underlying chmod() function in the C library just sets or
 * clears the READONLY attribute. It does not touch any ACL. Software
 * that needs to manage file permissions on Windows exactly should
 * use the Win32 API.
 * See the C library manual for more details about chmod().
 * Returns: zero if the operation succeeded, -1 on error.
 * Since: 2.8
g_chmod (const gchar *filename,
         int          mode)
#ifdef G_OS_WIN32
  wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
  int retval;
  int save_errno;
  if (wfilename == NULL)
      errno = EINVAL;
      return -1;

  retval = _wchmod (wfilename, mode);
  save_errno = errno;

  g_free (wfilename);

  errno = save_errno;
  return retval;
  return chmod (filename, mode);

Note: This has been introduced in glib 2.8 and would therefore increase
the current minimum glib version from 2.6 to 2.8.


Caspar Clemens Mierau

Caspar Clemens Mierau
 Dipl.-Kult. (Medien)
 official "Ubuntu member"
 ubuntu Deutschland e.V.
 Ubuntu Berlin
 c-base e.V.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.cypherpunks.ca/pipermail/otr-dev/attachments/20080617/d9630d19/attachment.pgp>

More information about the OTR-dev mailing list