clay-server 2.29.1 → 2.29.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/daemon.js +10 -6
- package/package.json +1 -1
package/lib/daemon.js
CHANGED
|
@@ -258,21 +258,25 @@ var relay = createServer({
|
|
|
258
258
|
var slugs = config.projects.map(function (p) { return p.slug; });
|
|
259
259
|
var slug = generateSlug(path.join(baseDir, repoName), slugs);
|
|
260
260
|
var targetDir = path.join(baseDir, slug);
|
|
261
|
-
//
|
|
261
|
+
// Clone as user to use their git credentials
|
|
262
262
|
var spawnOpts = { cwd: baseDir };
|
|
263
263
|
if (config.osUsers && wsUser && wsUser.linuxUser) {
|
|
264
264
|
try {
|
|
265
265
|
var passwdLine = execSync("id -u " + wsUser.linuxUser + " && id -g " + wsUser.linuxUser, { encoding: "utf8" }).trim().split("\n");
|
|
266
266
|
spawnOpts.uid = parseInt(passwdLine[0], 10);
|
|
267
267
|
spawnOpts.gid = parseInt(passwdLine[1], 10);
|
|
268
|
+
spawnOpts.env = Object.assign({}, process.env, {
|
|
269
|
+
HOME: "/home/" + wsUser.linuxUser,
|
|
270
|
+
USER: wsUser.linuxUser
|
|
271
|
+
});
|
|
268
272
|
} catch (e) {}
|
|
269
273
|
}
|
|
270
|
-
// Pre-create target directory and chown to user
|
|
274
|
+
// Pre-create target directory as root and chown to user
|
|
275
|
+
if (fs.existsSync(targetDir)) {
|
|
276
|
+
callback({ ok: false, error: "Target directory already exists: " + targetDir });
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
271
279
|
if (config.osUsers && wsUser && wsUser.linuxUser && spawnOpts.uid != null) {
|
|
272
|
-
if (fs.existsSync(targetDir)) {
|
|
273
|
-
callback({ ok: false, error: "Target directory already exists: " + targetDir });
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
280
|
try {
|
|
277
281
|
fs.mkdirSync(targetDir, { mode: 0o700 });
|
|
278
282
|
fs.chownSync(targetDir, spawnOpts.uid, spawnOpts.gid);
|