Changeset 165b0c9


Ignore:
Timestamp:
Jul 16, 2011, 12:29:19 AM (13 years ago)
Author:
GitHub Merge Button <merge-button@github.com>
Parents:
c6332f5 (diff), f6ab6ee (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge f6ab6ee703220c4fbafada73532fbcdc3454705a into c6332f56e9c66ca3e95915c3678d8f2426a46598
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • barnowl

    rb14f8cb rf5f6ec0  
    88
    99if test ! -x "$EXE"; then
    10     echo "Cannot find barnowl.bin" >&2
     10    echo "Cannot find $EXE" >&2
    1111    exit 1
    1212fi
  • functions.c

    rdde1b4d r99ac28a  
    32263226      } else if (myargc > 0) {
    32273227        /* Spawn the child. */
    3228         pid_t pid;
     3228        GPid pid;
    32293229        GError *error = NULL;
    32303230        owl_function_debugmsg("About to exec \"%s\" with %d arguments", argv[0], myargc);
  • runtests.sh

    r786a410 rf6ab6ee  
    11#!/bin/sh
    2 SRCDIR=`dirname "${0}"`
    3 
    4 export BARNOWL_DATA_DIR="$SRCDIR/perl/"
    5 export BARNOWL_BIN_DIR="$SRCDIR/"
    6 
    7 HARNESS_PERL=./tester exec prove --failures t/
     2exec env HARNESS_PERL=./tester prove --failures t/
  • scripts/locker-build

    r401752a r055e366  
    8585    BARNOWL="/afs/sipb.mit.edu/project/barnowl/arch/$ATHENA_SYS"
    8686    export PKG_CONFIG_PATH="$BARNOWL/lib/pkgconfig"
     87    eval $("$BARNOWL/bin/barnowl-perl-config")
    8788
    8889    SUFFIX=
  • t/completion.t

    r3001c11 re59d775  
    323323}
    324324
    325 mkpath("$tmpdir/.owl/",
    326        "$tmpdir/.owl/modules/",
    327        "$tmpdir/Public/",
    328        "$tmpdir/Private/",
    329        "$tmpdir/.ours",
    330        "$tmpdir/www",
    331      {mode => 0700});
     325mkpath(["$tmpdir/.owl/",
     326        "$tmpdir/.owl/modules/",
     327        "$tmpdir/Public/",
     328        "$tmpdir/Private/",
     329        "$tmpdir/.ours",
     330        "$tmpdir/www"],
     331       0, 0700);
    332332touch("$tmpdir/.zephyr.subs");
    333333touch("$tmpdir/wheee");
  • t/unicode.t

    r09ff1eb rf415f83  
    55use Encode;
    66
    7 BEGIN { bootstrap BarnOwl; };
     7use Test::More qw(no_plan);
    88
    9 use Test::More qw(no_plan);
     9use BarnOwl;
    1010
    1111my $unicode = "“hello”";
  • tester.c

    r14c9e05 r0ba7333  
    44#undef WINDOW
    55
    6 #include <errno.h>
    76#include <unistd.h>
    8 #include <pwd.h>
    97#include <stdio.h>
    108#include <stdlib.h>
    119#include <string.h>
    12 #include <sys/types.h>
    1310
    1411#undef instr
     
    136133{
    137134  int numfailed=0;
    138   const char *home;
    139   char *s, *path;
    140   struct passwd *pw;
     135  char *s, *path, *home;
    141136
    142137  printf("# BEGIN testing owl_util\n");
     
    227222                "\"");
    228223
    229   GString *g = g_string_new("");
    230   owl_string_appendf_quoted(g, "%q foo %q%q %s %", "hello", "world is", "can't");
     224  GString *quoted = g_string_new("");
     225  owl_string_appendf_quoted(quoted, "%q foo %q%q %s %", "hello", "world is", "can't");
    231226  FAIL_UNLESS("owl_string_appendf",
    232               !strcmp(g->str, "hello foo 'world is'\"can't\" %s %"));
    233   g_string_free(g, true);
     227              !strcmp(quoted->str, "hello foo 'world is'\"can't\" %s %"));
     228  g_string_free(quoted, true);
    234229
    235230
     
    274269  g_free(s);
    275270
    276   errno = 0;
    277   pw = getpwuid(getuid());
    278   if (pw) {
    279     home = pw->pw_dir;
    280   } else {
    281     /* Just make some noise so we notice. */
    282     home = "<WHAT>";
    283     fprintf(stderr, "getpwuid: %s", errno ? strerror(errno) : "No such user");
    284   }
     271  home = g_strdup(owl_global_get_homedir(&g));
    285272  s = owl_util_makepath("~");
    286273  FAIL_UNLESS("makepath ~", !strcmp(home, s));
    287274  g_free(s);
    288275
    289   path = g_strconcat(home, "/foo/bar/baz", NULL);
     276  path = g_build_filename(home, "foo/bar/baz", NULL);
    290277  s = owl_util_makepath("~///foo/bar//baz");
    291278  FAIL_UNLESS("makepath ~///foo/bar//baz", !strcmp(path, s));
    292279  g_free(s);
    293280  g_free(path);
    294 
    295   errno = 0;
    296   pw = getpwnam("root");
    297   if (pw) {
    298     home = pw->pw_dir;
    299   } else {
     281  g_free(home);
     282
     283  home = owl_util_homedir_for_user("root");
     284  if (home == NULL) {
    300285    /* Just make some noise so we notice. */
    301     home = "<WHAT>";
    302     fprintf(stderr, "getpwnam: %s", errno ? strerror(errno) : "No such user");
     286    home = g_strdup("<WHAT>");
     287    fprintf(stderr, "owl_util_homedir_for_user failed");
    303288  }
    304289
     
    307292  g_free(s);
    308293
    309   path = g_strconcat(home, "/foo/bar/baz", NULL);
     294  path = g_build_filename(home, "foo/bar/baz", NULL);
    310295  s = owl_util_makepath("~root///foo/bar//baz");
    311296  FAIL_UNLESS("makepath ~root///foo/bar//baz", !strcmp(path, s));
    312297  g_free(s);
    313298  g_free(path);
     299  g_free(home);
    314300
    315301  /* if (numfailed) printf("*** WARNING: failures encountered with owl_util\n"); */
  • util.c

    rdde1b4d r8219374  
    3232}
    3333
     34CALLER_OWN char *owl_util_homedir_for_user(const char *name)
     35{
     36  int err;
     37  struct passwd pw_buf;
     38  struct passwd *pw;
     39
     40  char *pw_strbuf, *ret;
     41  long pw_strbuf_len = sysconf(_SC_GETPW_R_SIZE_MAX);
     42  if (pw_strbuf_len < 0) {
     43    /* If we really hate ourselves, we can be fancy and loop until we stop
     44     * getting ERANGE. For now just pick a random number. */
     45    owl_function_error("owl_util_homedir_for_user: Could not get _SC_GETPW_R_SIZE_MAX");
     46    pw_strbuf_len = 16384;
     47  }
     48  pw_strbuf = g_new0(char, pw_strbuf_len);
     49  err = getpwnam_r(name, &pw_buf, pw_strbuf, pw_strbuf_len, &pw);
     50  if (err) {
     51    owl_function_error("getpwuid_r: %s", strerror(err));
     52    /* Fall through; pw will be NULL. */
     53  }
     54  ret = pw ? g_strdup(pw->pw_dir) : NULL;
     55  g_free(pw_strbuf);
     56  return ret;
     57}
     58
    3459/* Return a "nice" version of the path.  Tilde expansion is done, and
    3560 * duplicate slashes are removed.  Caller must free the return.
     
    4267    /* Attempt tilde-expansion of the first component. Get the
    4368       tilde-prefix, which goes up to the next slash. */
    44     struct passwd *pw;
    4569    const char *end = strchr(in + 1, '/');
    4670    if (end == NULL)
    4771      end = in + strlen(in);
    4872
     73    /* Patch together a new path. Replace the ~ and tilde-prefix with
     74       the homedir, if available. */
    4975    if (end == in + 1) {
    50       /* My home directory. */
    51       pw = getpwuid(getuid());
     76      /* My home directory. Use the one in owl_global for consistency with
     77       * owl_zephyr_dotfile. */
     78      out = g_strconcat(owl_global_get_homedir(&g), end, NULL);
    5279    } else {
    5380      /* Someone else's home directory. */
    5481      char *user = g_strndup(in + 1, end - (in + 1));
    55       pw = getpwnam(user);
     82      char *home = owl_util_homedir_for_user(user);
     83      if (home) {
     84        out = g_strconcat(home, end, NULL);
     85      } else {
     86        out = g_strdup(in);
     87      }
     88      g_free(home);
    5689      g_free(user);
    5790    }
    58 
    59     /* Patch together a new path. Replace the ~ and tilde-prefix with
    60        the homedir. */
    61     if (pw) {
    62       out = g_strconcat(pw->pw_dir, end, NULL);
    63     } else {
    64       out = g_strdup(in);
    65     }
    6691  } else {
    67       out = g_strdup(in);
     92    out = g_strdup(in);
    6893  }
    6994
Note: See TracChangeset for help on using the changeset viewer.