darcs

Issue 163 careful_atomic_create breaks on hostnamesm with colons in them

Title careful_atomic_create breaks on hostnamesm with colons in them
Priority wishlist Status resolved
Milestone Resolved in
Superseder Nosy List darcs-devel, dmitry.kurochkin, jch, kowey, markstos, thorkilnaur, tommy
Assigned To
Topics

Created on 2006-04-23.23:06:07 by jch, last changed 2009-08-27.14:04:19 by admin.

Messages
msg623 (view) Author: jch Date: 2006-04-23.23:06:06
Careful_atomic_create in atomic_create.c first creates a temporary
lock file that depends on the hostname.  It then attempts to hard link
it to the actual lock file.

If the filesystem doesn't support hard links (e.g. we're using FAT),
careful_atomic_create falls back to the sloppy strategy.

Interestingly, some people choose to have colons in the hostname of
their machine (which violates RFC 952 and has interesting side-effects
when using X).  In that case, creation of the temporary filename
fails, which causes grief and suffering.

The obvious fix is to shoot people who put colons in hostnames.

The other obvious fix is to replace all weird characters with dashes
in careful_atomic_create.

                                        Juliusz
msg2874 (view) Author: markstos Date: 2008-01-30.00:51:13
jch recommended replacing "all weird characters" in careful_atomic create with
dashes. Which "weird characters" are being referred to here? Perhaps this
sprintf statement? 

    rc = snprintf(filename + dirlen, FILENAME_SIZE, "darcs_lock_%s%04x%04x",
                  hostname, ((unsigned)getpid()) & 0xFFFF,
                  ((unsigned)(now.tv_usec ^ (now.tv_usec >> 16))) & 0xFFFF);
msg2905 (view) Author: droundy Date: 2008-01-30.16:47:20
On Wed, Jan 30, 2008 at 12:51:14AM -0000, Mark Stosberg wrote:
> jch recommended replacing "all weird characters" in careful_atomic create with
> dashes. Which "weird characters" are being referred to here? Perhaps this
> sprintf statement? 
> 
>     rc = snprintf(filename + dirlen, FILENAME_SIZE, "darcs_lock_%s%04x%04x",
>                   hostname, ((unsigned)getpid()) & 0xFFFF,
>                   ((unsigned)(now.tv_usec ^ (now.tv_usec >> 16))) & 0xFFFF);

That looks reasonable.
-- 
David Roundy
Department of Physics
Oregon State University
msg4278 (view) Author: jch Date: 2008-04-21.14:25:02
> jch recommended replacing "all weird characters" in careful_atomic create with
> dashes. Which "weird characters" are being referred to here? Perhaps this
> sprintf statement?

Yep.  Just after getting the hostname, do something like (untested):

  n = strlen(hostname);
  for(i = 0; i < n; i++) {
      c = hostname[i];
      if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
         (c >= '0' && c <= '9') || c == '-' || c == '_')
          continue;
      hostname[i] = '-';
  }

                                        Juliusz
History
Date User Action Args
2006-04-23 23:06:07jchcreate
2008-01-30 00:51:14markstossetstatus: unread -> unknown
nosy: + markstos, kowey, beschmi
messages: + msg2874
title: careful_atomic_create breaks when people are stupid -> careful_atomic_create breaks on hostnamesm with colons in them
2008-01-30 16:47:21droundysetnosy: droundy, jch, tommy, beschmi, kowey, markstos
messages: + msg2905
2008-02-11 01:29:37markstossetstatus: unknown -> deferred
nosy: droundy, jch, tommy, beschmi, kowey, markstos
title: careful_atomic_create breaks on hostnamesm with colons in them -> wish: careful_atomic_create breaks on hostnames with colons in them
2008-03-28 19:34:52droundysetstatus: deferred -> resolved-in-unstable
nosy: droundy, jch, tommy, beschmi, kowey, markstos
2008-04-21 14:25:04jchsetnosy: droundy, jch, tommy, beschmi, kowey, markstos
messages: + msg4278
title: wish: careful_atomic_create breaks on hostnames with colons in them -> careful_atomic_create breaks on hostnamesm with colons in them
2008-09-04 21:28:19adminsetstatus: resolved-in-unstable -> resolved
nosy: + dagit
2009-08-06 17:41:44adminsetnosy: + jast, Serware, dmitry.kurochkin, darcs-devel, zooko, mornfall, simon, thorkilnaur, - droundy, jch
2009-08-06 20:49:37adminsetnosy: - beschmi
2009-08-10 21:45:02adminsetnosy: + jch, - darcs-devel, zooko, jast, Serware, mornfall
2009-08-10 23:53:55adminsetnosy: - dagit
2009-08-25 17:55:20adminsetnosy: + darcs-devel, - simon
2009-08-27 14:04:19adminsetnosy: jch, tommy, kowey, markstos, darcs-devel, thorkilnaur, dmitry.kurochkin