@@ -12,7 +12,7 @@ import {
1212} from '../lib/data'
1313import { Mapping } from '../types/general'
1414import prodConfigure from '../../scripts/prod.config.js'
15- import { getGitUserId } from '../helpers/getGitUser'
15+ import { getGitUserId , getGitGroupId } from '../helpers/getGitUser'
1616import environment from '../helpers/environment'
1717const mappingRouter = express . Router ( )
1818const exec = util . promisify ( cp . exec )
@@ -61,7 +61,7 @@ mappingRouter.post('/', async (req, res) => {
6161 port : req . body . port || `${ portCounter } ` ,
6262 ip : req . body . ip || '127.0.0.1' ,
6363 id : uuid4 ( ) ,
64- gitLink : `myproxy @${ req . body . domain } :${ WORKPATH } /${ fullDomain } ` ,
64+ gitLink : `git @${ req . body . domain } :${ WORKPATH } /${ fullDomain } ` ,
6565 fullDomain
6666 }
6767 domainKeys . push ( mappingObject )
@@ -72,9 +72,14 @@ mappingRouter.post('/', async (req, res) => {
7272 if ( ! isProduction ( ) ) {
7373 return respond ( )
7474 }
75+
76+ // get user and group id to execute the commands with the correct permissions
7577 const gitUserId = await getGitUserId ( )
78+ const gitGroupId = await getGitGroupId ( )
79+
7680 exec (
7781 `
82+ umask 002
7883 cd ${ WORKPATH }
7984 mkdir ${ fullDomain }
8085 git init ${ fullDomain }
@@ -88,7 +93,7 @@ mappingRouter.post('/', async (req, res) => {
8893 git add .
8994 git commit -m "Initial Commit"
9095 ` ,
91- { uid : gitUserId }
96+ { uid : gitUserId , gid : gitGroupId }
9297 )
9398 . then ( ( ) => {
9499 respond ( )
@@ -126,7 +131,11 @@ mappingRouter.delete('/:id', async (req, res) => {
126131 const deletedDomain = getMappingById ( req . params . id )
127132 deleteDomain ( deletedDomain . fullDomain )
128133 if ( ! isProduction ( ) ) return res . json ( deletedDomain )
134+
135+ // get user and group id to execute the commands with the correct permissions
129136 const gitUserId = await getGitUserId ( )
137+ const gitGroupId = await getGitGroupId ( )
138+
130139 exec (
131140 `
132141 cd ${ WORKPATH }
@@ -136,7 +145,7 @@ mappingRouter.delete('/:id', async (req, res) => {
136145 fi
137146 rm -rf ${ deletedDomain . fullDomain }
138147 ` ,
139- { uid : gitUserId }
148+ { uid : gitUserId , gid : gitGroupId }
140149 ) . then ( ( ) => {
141150 res . json ( deletedDomain )
142151 } )
0 commit comments