Example #1
0
 function(cb) {
   var gg = passwd.getGroups()
     .on('group', function(group_data) {
       if (group_data.gid == gid)
         gid_present = true;
     })
     .on('end', function() {
       if (!gid_present)
         cb('GID ' + gid + ' does not exist on this system');
       else
         cb();
     })
 }
Example #2
0
		return function(callback) {

			// no group specified
			if(!_task.getParam('group'))
				return callback();

			passwd.getGroups()
				.on('group', function(group) {
					if(group.groupname === _task.getParam('group')) {
						_log.info("Group '" + _task.getParam('group') + " is already present on the system");
						_groupPresent = true;
					}
				})
				.on('end', function() {
					callback();
				});
		};
Example #3
0
auth.test_membership = function(username, group, callback) {
  var passwd = require('etc-passwd');
  var userid = require('userid');

  var membership_valid = false;
  var gg = passwd.getGroups()
    .on('group', function(group_data) {
      if (group == group_data.groupname)
        try {
          if (group_data.users.indexOf(username) >= 0 || group_data.gid == userid.gid(username)) 
            membership_valid = true;
        } catch (e) {}
    })
    .on('end', function() {
      callback(membership_valid);
    })
}
Example #4
0
function amass_etc_passwd(cb) {
  var data = {};
  var errors = [];

  passwd.getUsers(passwdcb('users'));
  passwd.getGroups(passwdcb('groups'));

  var i = 0;
  function passwdcb(type) {
    return function(err, d) {
      if (err) errors.push(err);
      else data[type] = d;

      if (++i === 2) done();
    };
  }

  function done() {
    cb(errors.length ? errors : null, data);
  }
}