Skip to content

Commit

Permalink
User hint
Browse files Browse the repository at this point in the history
Show a hint to the user when setting permissions failed due to insufficient permissions
  • Loading branch information
bezoerb committed Apr 1, 2015
1 parent 46e31c2 commit 69824e8
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,25 +141,35 @@ var AppGenerator = yeoman.generators.Base.extend({
'HTTPDUSER=`ps aux | grep -E \'[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx\' | grep -v root | head -1 | cut -d\\ -f1`',
'chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs',
'chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs'
].join(';'),
],

// Use ACL on a system that does not support chmod +a
setfacl: [
'HTTPDUSER=`ps aux | grep -E \'[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx\' | grep -v root | head -1 | cut -d\\ -f1`',
'setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs',
'setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs'
].join(';')
]
};


exec(acl.chmod, [], function (err) {
exec(acl.chmod.join(';'), [], function (err, stdout, stderr) {
if (!err) {
return cb();
} else if (/not\spermitted/.test(stderr)) {
this.log(chalk.bold.red('Warning: ') + 'I failed setting the folder permissions. Run the following command as admin as soon as i\'m done:' );
this.log(chalk.yellow(acl.chmod.join(os.EOL)));
this.log('');
return cb();
}

exec(acl.setfacl, [], function (err) {
exec(acl.setfacl.join(';'), [], function (err, stdout, stderr) {
if (!err) {
return cb();
} else if (/not\spermitted/.test(stderr)) {
this.log(chalk.bold.red('Warning: ') + 'I failed setting the folder permissions. Run the following command as admin as soon as i\'m done:' );
this.log(chalk.yellow(acl.setfacl.join(os.EOL)));
this.log('');
return cb();
}

this.log('Your system doesn\'t support ACL. Setting permissions via ' + chalk.bold.yellow('umask'));
Expand Down

0 comments on commit 69824e8

Please sign in to comment.