Fossil

Changes On Branch backoffice-win
Login

Changes On Branch backoffice-win

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch backoffice-win Excluding Merge-Ins

This is equivalent to a diff from 1dd2527f to 5d7c00f7

2019-05-02
03:36
tclsh8.7 is out there... ... (check-in: 8b276cf9 user: bch tags: trunk)
2019-04-26
16:53
Another invocation of the backoffice was found where the option "--nocgi" might be necessary. ... (Closed-Leaf check-in: 5d7c00f7 user: tsbg tags: backoffice-win)
16:45
Make sure that the "--nocgi" option gets removed from the command line (hint: short circuit evaluation of the && operator). ... (check-in: 417e2b41 user: tsbg tags: backoffice-win)
16:39
Merge trunk. ... (check-in: 3a19db88 user: tsbg tags: backoffice-win)
2019-04-25
14:28
Make full use of the new file_tempname() in "fossil diff" with both --from and --to options. Improve file_tempname() to allow for a suggested differentiator tag. ... (check-in: 1dd2527f user: drh tags: trunk)
2019-04-24
12:59
Preserve the basis-file suffix when generating temporary file names. ... (check-in: a072be1e user: drh tags: trunk)

Changes to src/alerts.c.

841
842
843
844
845
846
847

848





849
850

851



852
853
854
855
856
857
858
    }
    rc = sqlite3_reset(p->pStmt);
    if( rc!=SQLITE_OK ){
      emailerError(p, "Failed to insert email message into output queue.\n"
                      "%s", sqlite3_errmsg(p->db));
    }
  }else if( p->zCmd ){

    FILE *out = popen(p->zCmd, "w");





    if( out ){
      fwrite(blob_buffer(&all), 1, blob_size(&all), out);

      pclose(out);



    }else{
      emailerError(p, "Could not open output pipe \"%s\"", p->zCmd);
    }
  }else if( p->zDir ){
    char *zFile = file_time_tempname(p->zDir, ".email");
    blob_write_to_file(&all, zFile);
    fossil_free(zFile);







>

>
>
>
>
>


>

>
>
>







841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
    }
    rc = sqlite3_reset(p->pStmt);
    if( rc!=SQLITE_OK ){
      emailerError(p, "Failed to insert email message into output queue.\n"
                      "%s", sqlite3_errmsg(p->db));
    }
  }else if( p->zCmd ){
#if !defined(_WIN32)
    FILE *out = popen(p->zCmd, "w");
#else
    int in, pid;
    FILE *out;
    popen2(p->zCmd, &in, &out, &pid);
#endif
    if( out ){
      fwrite(blob_buffer(&all), 1, blob_size(&all), out);
#if !defined(_WIN32)
      pclose(out);
#else
      pclose2(in ,out, pid);
#endif
    }else{
      emailerError(p, "Could not open output pipe \"%s\"", p->zCmd);
    }
  }else if( p->zDir ){
    char *zFile = file_time_tempname(p->zDir, ".email");
    blob_write_to_file(&all, zFile);
    fossil_free(zFile);

Changes to src/backoffice.c.

282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
** we cannot prove the the process is dead, return true.
*/
static int backofficeProcessExists(sqlite3_uint64 pid){
#if defined(_WIN32)
  return pid>0 && backofficeWin32ProcessExists((DWORD)pid)!=0;
#else
  return pid>0 && kill((pid_t)pid, 0)==0;
#endif 
}

/*
** Check to see if the process identified by pid has finished.  If
** we cannot prove the the process is still running, return true.
*/
static int backofficeProcessDone(sqlite3_uint64 pid){
#if defined(_WIN32)
  return pid<=0 || backofficeWin32ProcessExists((DWORD)pid)==0;
#else
  return pid<=0 || kill((pid_t)pid, 0)!=0;
#endif 
}

/*
** Return a process id number for the current process
*/
static sqlite3_uint64 backofficeProcessId(void){
  return (sqlite3_uint64)GETPID();







|











|







282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
** we cannot prove the the process is dead, return true.
*/
static int backofficeProcessExists(sqlite3_uint64 pid){
#if defined(_WIN32)
  return pid>0 && backofficeWin32ProcessExists((DWORD)pid)!=0;
#else
  return pid>0 && kill((pid_t)pid, 0)==0;
#endif
}

/*
** Check to see if the process identified by pid has finished.  If
** we cannot prove the the process is still running, return true.
*/
static int backofficeProcessDone(sqlite3_uint64 pid){
#if defined(_WIN32)
  return pid<=0 || backofficeWin32ProcessExists((DWORD)pid)==0;
#else
  return pid<=0 || kill((pid_t)pid, 0)!=0;
#endif
}

/*
** Return a process id number for the current process
*/
static sqlite3_uint64 backofficeProcessId(void){
  return (sqlite3_uint64)GETPID();
468
469
470
471
472
473
474


475
476
477
478
479
480
481
      x.idNext = 0;
      x.tmNext = 0;
      backofficeWriteLease(&x);
      db_end_transaction(0);
      backofficeTrace("/***** Begin Backoffice Processing %d *****/\n",
                      GETPID());
      backoffice_work();


      break;
    }
    if( backofficeNoDelay || db_get_boolean("backoffice-nodelay",0) ){
      /* If the no-delay flag is set, exit immediately rather than queuing
      ** up.  Assume that some future request will come along and handle any
      ** necessary backoffice work. */
      db_end_transaction(0);







>
>







468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
      x.idNext = 0;
      x.tmNext = 0;
      backofficeWriteLease(&x);
      db_end_transaction(0);
      backofficeTrace("/***** Begin Backoffice Processing %d *****/\n",
                      GETPID());
      backoffice_work();
      backofficeTrace("/***** End Backoffice Processing %d *****/\n",
                      GETPID());
      break;
    }
    if( backofficeNoDelay || db_get_boolean("backoffice-nodelay",0) ){
      /* If the no-delay flag is set, exit immediately rather than queuing
      ** up.  Assume that some future request will come along and handle any
      ** necessary backoffice work. */
      db_end_transaction(0);
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
      time_t iNext = time(0);
      for(i=2; i<g.argc; i++){
        Blob cmd;
        if( !file_isfile(g.argv[i], ExtFILE) ) continue;
        if( iNow && iNow>file_mtime(g.argv[i],ExtFILE) ) continue;
        blob_init(&cmd, 0, 0);
        blob_append_escaped_arg(&cmd, g.nameOfExe);
        blob_append(&cmd, " backoffice --nodelay", -1);
        if( g.fAnyTrace ){
          blob_append(&cmd, " --trace", -1);
        }
        blob_append_escaped_arg(&cmd, g.argv[i]);
        nCmd++;
        if( bDebug ){
          fossil_print("COMMAND[%u]: %s\n", nCmd, blob_str(&cmd));







|







600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
      time_t iNext = time(0);
      for(i=2; i<g.argc; i++){
        Blob cmd;
        if( !file_isfile(g.argv[i], ExtFILE) ) continue;
        if( iNow && iNow>file_mtime(g.argv[i],ExtFILE) ) continue;
        blob_init(&cmd, 0, 0);
        blob_append_escaped_arg(&cmd, g.nameOfExe);
        blob_append(&cmd, " backoffice --nocgi --nodelay", -1);
        if( g.fAnyTrace ){
          blob_append(&cmd, " --trace", -1);
        }
        blob_append_escaped_arg(&cmd, g.argv[i]);
        nCmd++;
        if( bDebug ){
          fossil_print("COMMAND[%u]: %s\n", nCmd, blob_str(&cmd));
641
642
643
644
645
646
647


648
649
650
651
652



653
654
655
656
657
658

















659



660
661
662
663

664
665
666
667
668
669
670
void backoffice_run_if_needed(void){
  if( backofficeDb==0 ) return;
  if( strcmp(backofficeDb,"x")==0 ) return;
  if( g.db ) return;
  if( g.repositoryOpen ) return;
#if defined(_WIN32)
  {


    int i;
    intptr_t x;
    char *argv[4];
    wchar_t *ax[5];
    argv[0] = g.nameOfExe;



    argv[1] = "backoffice";
    argv[2] = "-R";
    argv[3] = backofficeDb;
    ax[4] = 0;
    for(i=0; i<=3; i++) ax[i] = fossil_utf8_to_unicode(argv[i]);
    x = _wspawnv(_P_NOWAIT, ax[0], (const wchar_t * const *)ax);

















    for(i=0; i<=3; i++) fossil_unicode_free(ax[i]);



    backofficeTrace(
      "/***** Subprocess %d creates backoffice child %lu *****/\n",
      GETPID(), GetProcessId((HANDLE)x));
    if( x>=0 ) return;

  }
#else /* unix */
  {
    pid_t pid = fork();
    if( pid>0 ){
      /* This is the parent in a successful fork().  Return immediately. */
      backofficeTrace(







>
>
|
|
<
|
<
>
>
>
|
<
|
<
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
|
|
|
|
>







643
644
645
646
647
648
649
650
651
652
653

654

655
656
657
658

659

660

661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
void backoffice_run_if_needed(void){
  if( backofficeDb==0 ) return;
  if( strcmp(backofficeDb,"x")==0 ) return;
  if( g.db ) return;
  if( g.repositoryOpen ) return;
#if defined(_WIN32)
  {
    STARTUPINFOW si;
    PROCESS_INFORMATION pi;
    BOOL rc;
    Blob binCmd;

    wchar_t *wcsCmd;

    /* Build the command string and make sure the process does not get
    ** handled as CGI. */
    blob_zero(&binCmd);
    blob_appendf(&binCmd, "\"%s\" backoffice --nocgi -R \"%s\"",

                 g.nameOfExe, backofficeDb);

    wcsCmd = fossil_utf8_to_unicode(blob_str(&binCmd));

    blob_reset(&binCmd);
    /* Start a detached process. */
    ZeroMemory(&pi, sizeof(pi));
    ZeroMemory(&si, sizeof(si));
    si.cb = sizeof(si);
    rc = CreateProcessW(
       NULL,             /* Application Name */
       wcsCmd,           /* Command-line */
       NULL,             /* Process attributes */
       NULL,             /* Thread attributes */
       FALSE,            /* Inherit Handles */
       DETACHED_PROCESS, /* Create flags  */
       NULL,             /* Environment */
       NULL,             /* Current directory */
       &si,              /* Startup Info */
       &pi               /* Process Info */
    );
    fossil_unicode_free(wcsCmd);
    if( rc ){
      CloseHandle(pi.hProcess);
      CloseHandle(pi.hThread);
      backofficeTrace(
        "/***** Subprocess %d creates backoffice child %d *****/\n",
        GETPID(), pi.dwProcessId);
      return;
    }
  }
#else /* unix */
  {
    pid_t pid = fork();
    if( pid>0 ){
      /* This is the parent in a successful fork().  Return immediately. */
      backofficeTrace(

Changes to src/main.c.

680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
    sqlite3_vfs *pVfs = sqlite3_vfs_find(g.zVfsName);
    if( pVfs ){
      sqlite3_vfs_register(pVfs, 1);
    }else{
      fossil_fatal("no such VFS: \"%s\"", g.zVfsName);
    }
  }
  if( fossil_getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
    zCmdName = "cgi";
    g.isHTTP = 1;
  }else if( g.argc<2 && !fossilExeHasAppendedRepo() ){
    fossil_print(
       "Usage: %s COMMAND ...\n"
       "   or: %s help           -- for a list of common commands\n"
       "   or: %s help COMMAND   -- for help with the named command\n",







|







680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
    sqlite3_vfs *pVfs = sqlite3_vfs_find(g.zVfsName);
    if( pVfs ){
      sqlite3_vfs_register(pVfs, 1);
    }else{
      fossil_fatal("no such VFS: \"%s\"", g.zVfsName);
    }
  }
  if( !find_option("nocgi", 0, 0) && fossil_getenv("GATEWAY_INTERFACE")!=0 ){
    zCmdName = "cgi";
    g.isHTTP = 1;
  }else if( g.argc<2 && !fossilExeHasAppendedRepo() ){
    fossil_print(
       "Usage: %s COMMAND ...\n"
       "   or: %s help           -- for a list of common commands\n"
       "   or: %s help COMMAND   -- for help with the named command\n",
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
  noJail = find_option("nojail",0,0)!=0;
  allowRepoList = find_option("repolist",0,0)!=0;
  g.useLocalauth = find_option("localauth", 0, 0)!=0;
  g.sslNotAvailable = find_option("nossl", 0, 0)!=0;
  g.fNoHttpCompress = find_option("nocompress",0,0)!=0;
  zInFile = find_option("in",0,1);
  if( zInFile ){
    backoffice_disable();
    g.httpIn = fossil_fopen(zInFile, "rb");
    if( g.httpIn==0 ) fossil_fatal("cannot open \"%s\" for reading", zInFile);
  }else{
    g.httpIn = stdin;
  }
  zOutFile = find_option("out",0,1);
  if( zOutFile ){







<







2280
2281
2282
2283
2284
2285
2286

2287
2288
2289
2290
2291
2292
2293
  noJail = find_option("nojail",0,0)!=0;
  allowRepoList = find_option("repolist",0,0)!=0;
  g.useLocalauth = find_option("localauth", 0, 0)!=0;
  g.sslNotAvailable = find_option("nossl", 0, 0)!=0;
  g.fNoHttpCompress = find_option("nocompress",0,0)!=0;
  zInFile = find_option("in",0,1);
  if( zInFile ){

    g.httpIn = fossil_fopen(zInFile, "rb");
    if( g.httpIn==0 ) fossil_fatal("cannot open \"%s\" for reading", zInFile);
  }else{
    g.httpIn = stdin;
  }
  zOutFile = find_option("out",0,1);
  if( zOutFile ){

Changes to src/popen.c.

91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
  si.hStdError  = hErr;
  rc = CreateProcessW(
     NULL,  /* Application Name */
     zCmd,  /* Command-line */
     NULL,  /* Process attributes */
     NULL,  /* Thread attributes */
     TRUE,  /* Inherit Handles */
     0,     /* Create flags  */
     NULL,  /* Environment */
     NULL,  /* Current directory */
     &si,   /* Startup Info */
     &pi    /* Process Info */
  );
  if( rc ){
    CloseHandle( pi.hProcess );







|







91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
  si.hStdError  = hErr;
  rc = CreateProcessW(
     NULL,  /* Application Name */
     zCmd,  /* Command-line */
     NULL,  /* Process attributes */
     NULL,  /* Thread attributes */
     TRUE,  /* Inherit Handles */
     CREATE_NO_WINDOW, /* Create flags  */
     NULL,  /* Environment */
     NULL,  /* Current directory */
     &si,   /* Startup Info */
     &pi    /* Process Info */
  );
  if( rc ){
    CloseHandle( pi.hProcess );