~ubuntu-branches/ubuntu/jaunty/xulrunner-1.9/jaunty

« back to all changes in this revision

Viewing changes to mozilla/toolkit/mozapps/update/src/updater/updater.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fabien Tassin, Sasa Bodiroza, Fabien Tassin, Alexander Sack
  • Date: 2008-09-02 11:54:00 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20080902115400-yfy26crvszpalvg5
Tags: 1.9.0.2+build3+nobinonly-0ubuntu1
[ Sasa Bodiroza ]
* In debian/rules:
  - Set 644 chmod to png files (LP: #252793) [Patch by Paolo Naldini]

[ Fabien Tassin ]
* improve create-build-system.sh to detect build-tree directory
  when embedded tarball is used. Fix un-escaped variables.
  Create build-system.tar.gz in the debian directory to prevent
  cdbs to check and unpack it during the build
  - update debian/create-build-system.sh
* Fix variables when an embedded tarball is used
  - update debian/rules
* Fix buffer overflow in realpath() at runtime and drop -U_FORTIFY_SOURCE
  from CPPFLAGS (LP: #263014)
  - add debian/patches/bz412610_att335369_realpath_overflow.patch
  - update debian/patches/series

[ Alexander Sack <asac@jwsdot.com> ]
* introduce preferred plugins by mime-type experimental feature;
  you can now set a pref to explicitly select a plugin to serve a particilar
  mime-type; patch contains further documentation.
  - add debian/patches/bzXXX_plugin_for_mimetype_pref.patch
  - update debian/patches/series
* drop patches applied upstream
  - drop bz120380_att326044.patch (fixed by bz442629)
  - update debian/patches/series

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 *
22
22
 * Contributor(s):
23
23
 *  Darin Fisher <darin@meer.net>
 
24
 *  Robert Strong <robert.bugzilla@gmail.com>
24
25
 *
25
26
 * Alternatively, the contents of this file may be used under the terms of
26
27
 * either the GNU General Public License Version 2 or later (the "GPL"), or
1101
1102
    L"\0"
1102
1103
  };
1103
1104
 
1104
 
  WinLaunchChild(exefullpath, argc, argv, 1);
 
1105
  WinLaunchChild(exefullpath, argc, argv, 0);
1105
1106
  free(argv);
1106
1107
}
1107
1108
#endif
1120
1121
#elif defined(XP_MACOSX)
1121
1122
  LaunchChild(argc, argv);
1122
1123
#elif defined(XP_WIN)
1123
 
  WinLaunchChild(argv[0], argc, argv, -1);
 
1124
  WinLaunchChild(argv[0], argc, argv, 0);
1124
1125
#else
1125
1126
# warning "Need implementaton of LaunchCallbackApp"
1126
1127
#endif
1212
1213
#endif
1213
1214
  }
1214
1215
 
 
1216
#ifdef XP_WIN
 
1217
  // Launch a second instance of the updater with the runas verb on Windows
 
1218
  // when write access is denied to the installation directory.
 
1219
 
 
1220
  NS_tchar updateLockFilePath[MAXPATHLEN];
 
1221
  NS_tsnprintf(updateLockFilePath, MAXPATHLEN,
 
1222
               NS_T("%s/update_in_progress.lock"), argv[3]);
 
1223
 
 
1224
  // The update_in_progress.lock file should only exist during an update. In
 
1225
  // case it exists attempt to remove it and exit if that fails to prevent
 
1226
  // simultaneous updates occurring.
 
1227
  if (!_waccess(updateLockFilePath, F_OK) &&
 
1228
      NS_tremove(updateLockFilePath) != 0) {
 
1229
    fprintf(stderr, "Update already in progress! Exiting\n");
 
1230
    return 1;
 
1231
  }
 
1232
 
 
1233
  HANDLE updateLockFileHandle;
 
1234
  updateLockFileHandle = CreateFileW(updateLockFilePath,
 
1235
                                     GENERIC_READ | GENERIC_WRITE,
 
1236
                                     0,
 
1237
                                     NULL,
 
1238
                                     OPEN_ALWAYS,
 
1239
                                     FILE_FLAG_DELETE_ON_CLOSE,
 
1240
                                     NULL);
 
1241
 
 
1242
  NS_tchar elevatedLockFilePath[MAXPATHLEN];
 
1243
  NS_tsnprintf(elevatedLockFilePath, MAXPATHLEN,
 
1244
               NS_T("%s/update_elevated.lock"), argv[1]);
 
1245
 
 
1246
  if (updateLockFileHandle == INVALID_HANDLE_VALUE) {
 
1247
    if (!_waccess(elevatedLockFilePath, F_OK) &&
 
1248
        NS_tremove(elevatedLockFilePath) != 0) {
 
1249
      fprintf(stderr, "Update already elevated! Exiting\n");
 
1250
      return 1;
 
1251
    }
 
1252
 
 
1253
    HANDLE elevatedFileHandle;
 
1254
    elevatedFileHandle = CreateFileW(elevatedLockFilePath,
 
1255
                                     GENERIC_READ | GENERIC_WRITE,
 
1256
                                     0,
 
1257
                                     NULL,
 
1258
                                     OPEN_ALWAYS,
 
1259
                                     FILE_FLAG_DELETE_ON_CLOSE,
 
1260
                                     NULL);
 
1261
 
 
1262
    if (elevatedFileHandle == INVALID_HANDLE_VALUE) {
 
1263
      fprintf(stderr, "Unable to create elevated lock file! Exiting\n");
 
1264
      return 1;
 
1265
    }
 
1266
 
 
1267
    PRUnichar *cmdLine = MakeCommandLine(argc - 1, argv + 1);
 
1268
    if (!cmdLine) {
 
1269
      CloseHandle(elevatedFileHandle);
 
1270
      return 1;
 
1271
    }
 
1272
 
 
1273
    SHELLEXECUTEINFO sinfo;
 
1274
    memset(&sinfo, 0, sizeof(SHELLEXECUTEINFO));
 
1275
    sinfo.cbSize       = sizeof(SHELLEXECUTEINFO);
 
1276
    sinfo.fMask        = SEE_MASK_FLAG_DDEWAIT |
 
1277
                         SEE_MASK_FLAG_NO_UI |
 
1278
                         SEE_MASK_NOCLOSEPROCESS;
 
1279
    sinfo.hwnd         = NULL;
 
1280
    sinfo.lpFile       = argv[0];
 
1281
    sinfo.lpParameters = cmdLine;
 
1282
    sinfo.lpVerb       = L"runas";
 
1283
    sinfo.nShow        = SW_SHOWNORMAL;
 
1284
 
 
1285
    BOOL result = ShellExecuteEx(&sinfo);
 
1286
    free(cmdLine);
 
1287
 
 
1288
    if (result) {
 
1289
      WaitForSingleObject(sinfo.hProcess, INFINITE);
 
1290
      CloseHandle(sinfo.hProcess);
 
1291
    }
 
1292
 
 
1293
    if (argc > 4)
 
1294
      LaunchCallbackApp(argv[3], argc - 4, argv + 4);
 
1295
 
 
1296
    CloseHandle(elevatedFileHandle);
 
1297
    return 0;
 
1298
  }
 
1299
#endif
 
1300
 
1215
1301
  gSourcePath = argv[1];
1216
1302
 
1217
1303
  LogInit();
1229
1315
#ifdef XP_WIN
1230
1316
  if (gSucceeded && argc > 4)
1231
1317
    LaunchWinPostProcess(argv[4]);
 
1318
  CloseHandle(updateLockFileHandle);
 
1319
  // If elevated return early and let the process that launched this process
 
1320
  // launch the callback application.
 
1321
  if (!_waccess(elevatedLockFilePath, F_OK) &&
 
1322
      NS_tremove(elevatedLockFilePath) != 0)
 
1323
    return 0;
1232
1324
#endif
1233
1325
 
1234
1326
  // The callback to execute is given as the last N arguments of our command