provide svn with permissions. @TODO this will have to be updated to take
    into account automated releases etc.
778425
def get_svn_login(realm, username, may_save):
    
    import getpass

    print "svn requires a password for the user %s:" % username
    pwd = ''
    while not pwd.strip():
        pwd = getpass.getpass("--> ")

    return True, username, pwd, False
926005
def allow_rwe(self, name):
        """"""
        assert name in PERMISSIONS.keys()
        os.chmod(self.file_path, PERMISSIONS[name]['all'])
163021
private function scanRolesAndPermissions(): void
    {
        $files = $this->helper->getConfigFilesSorted();

        if (!empty($files)) {
            foreach ($files as $filePath) {
                $config = json_decode(file_get_contents($filePath), true);

                if (is_null($config)) {
                    $this->info('Invalid json file: ' . $filePath);
                } else {
                    $packageName = Arr::get($config, 'general.packageName');

                    if (is_null($packageName)) {
                        $this->error('SKIPPING! Package must have a name! file: ' . $filePath);
                        continue;
                    }

                    if (array_key_exists('acl', $config)) {
                        $this->aclData[] = [
                            'packageName' => $packageName,
                            'acl' => Arr::get($config, 'acl'),
                        ];
                    }
                }
            }
        }
    }
97205
function assignPermissions (done) {
  async.map(defaults.permissions, function (pair, callback) {
    Role.addScopes(pair[0], pair[1], function (err, result) {
      callback(err, result)
    })
  }, function (err, results) {
    done(err, results)
  })
}
745962
public function providePermissions()
    {
        $category = _t(__CLASS__ . '.PERMISSION_CATEGORY', 'SilverWare pages');
        
        return [
            'SILVERWARE_PAGE_TEMPLATE_CHANGE' => [
                'category' => $category,
                'name' => _t(__CLASS__ . '.PERMISSION_TEMPLATE_CHANGE_NAME', 'Change templates for pages'),
                'help' => _t(__CLASS__ . '.PERMISSION_TEMPLATE_CHANGE_HELP', 'Ability to change templates for pages.'),
                'sort' => 100
            ],
            'SILVERWARE_PAGE_LAYOUT_CHANGE' => [
                'category' => $category,
                'name' => _t(__CLASS__ . '.PERMISSION_LAYOUT_CHANGE_NAME', 'Change layouts for pages'),
                'help' => _t(__CLASS__ . '.PERMISSION_LAYOUT_CHANGE_HELP', 'Ability to change layouts for pages.'),
                'sort' => 200
            ],
            'SILVERWARE_PAGE_SETTINGS_CHANGE' => [
                'category' => $category,
                'name' => _t(__CLASS__ . '.PERMISSION_SETTINGS_CHANGE_NAME', 'Change settings for pages'),
                'help' => _t(__CLASS__ . '.PERMISSION_SETTINGS_CHANGE_HELP', 'Ability to change settings for pages.'),
                'sort' => 300
            ]
        ];
    }
1304620
def require_x_permission(flag)
      if current_user && current_user_roles.any?{|ug| ug.admin?}
        # if role is admin, then ok
      elsif current_user && current_model_permissions.any?{|cp| cp.permitted?(flag)}
        # if enough permission, then ok
      else
        respond_to_permission_error
      end
    end
589493
public static void setPermissions(Path location, Optional<String> owner, Optional<String> group, FileSystem fs,
      FsPermission permission) {
    try {
      if (!owner.isPresent()) {
        return;
      }
      if (!group.isPresent()) {
        return;
      }
      fs.setOwner(location, owner.get(), group.get());
      fs.setPermission(location, permission);
      if (!fs.isDirectory(location)) {
        return;
      }
      for (FileStatus fileStatus : fs.listStatus(location)) {
        setPermissions(fileStatus.getPath(), owner, group, fs, permission);
      }
    } catch (IOException e) {
      log.warn("Exception occurred while trying to change permissions : " + e.getMessage());
    }
  }
483896
private function doSetPermissions(): void
    {
        $permissionMethod = $this->getConfig(Option::permissionMethod);
        $writableDirs = implode(' ', $this->getConfig(Option::writableDirs));
        $this->log(sprintf('<h2>Setting permissions for writable dirs using the "%s" method</>', $permissionMethod));

        if ('chmod' === $permissionMethod) {
            $this->runRemote(sprintf('chmod -R %s %s', $this->getConfig(Option::permissionMode), $writableDirs));

            return;
        }

        if ('chown' === $permissionMethod) {
            $this->runRemote(sprintf('sudo chown -RL %s %s', $this->getConfig(Option::permissionUser), $writableDirs));

            return;
        }

        if ('chgrp' === $permissionMethod) {
            $this->runRemote(sprintf('sudo chgrp -RH %s %s', $this->getConfig(Option::permissionGroup), $writableDirs));

            return;
        }

        if ('acl' === $permissionMethod) {
            $this->runRemote(sprintf('sudo setfacl -RL -m u:"%s":rwX -m u:`whoami`:rwX %s', $this->getConfig(Option::permissionUser), $writableDirs));
            $this->runRemote(sprintf('sudo setfacl -dRL -m u:"%s":rwX -m u:`whoami`:rwX %s', $this->getConfig(Option::permissionUser), $writableDirs));

            return;
        }

        throw new InvalidConfigurationException(sprintf('The "%s" permission method is not valid. Select one of the supported methods.', $permissionMethod));
    }
431632
public function main()
    {
        $this->setup('list');

        if ($this->oldVersion) {
            $this->svn->setOptions(['fetchmode' => VERSIONCONTROL_SVN_FETCHMODE_XML]);
            $output = $this->run(['--xml']);

            if (!($xmlObj = @simplexml_load_string($output))) {
                throw new BuildException("Failed to parse the output of 'svn list --xml'.");
            }

            $objects = $xmlObj->list->entry;
            $entries = [];

            foreach ($objects as $object) {
                $entries[] = [
                    'commit' => [
                        'revision' => (string) $object->commit['revision'],
                        'author' => (string) $object->commit->author,
                        'date' => (string) $object->commit->date
                    ],
                    'name' => (string) $object->name
                ];
            }
        } else {
            $output = $this->run([]);
            $entries = $output['list'][0]['entry'];
        }

        if ($this->orderDescending) {
            $entries = array_reverse($entries);
        }

        $result = null;
        $count = 0;

        foreach ($entries as $entry) {
            if ($this->limit > 0 && $count >= $this->limit) {
                break;
            }

            $result .= (!empty($result)) ? "\n" : '';
            $result .= $entry['commit']['revision'] . ' | ' . $entry['commit']['author'] . ' | ' . $entry['commit']['date'] . ' | ' . $entry['name'];
            $count++;
        }

        if (!empty($result)) {
            $this->project->setProperty($this->getPropertyName(), $result);
        } else {
            throw new BuildException("Failed to parse the output of 'svn list'.");
        }
    }
1196945
public function update()
    {
        $sync = !empty($this->request->query['sync']) ? true : false;
        if (AcoManager::buildAcos(null, $sync)) {
            $this->Flash->success(__d('user', 'Permissions tree was successfully updated!'));
        } else {
            $this->Flash->danger(__d('user', 'Some errors occur while updating permissions tree.'));
        }

        $this->title(__d('user', 'Update Permissions'));
        $this->redirect($this->referer());
    }
794483
public function registerPermission()
    {
        $app = $this->app;

        $app->bind('Stevemo\Cpanel\Permission\Repo\PermissionInterface', function($app)
        {
            return new PermissionRepository(new Permission, $app['events'], $app['config']);
        });

        $app->bind('Stevemo\Cpanel\Permission\Form\PermissionFormInterface', function($app)
        {
            return new PermissionForm(
                new PermissionValidator($app['validator'], new MessageBag),
                $app->make('Stevemo\Cpanel\Permission\Repo\PermissionInterface')
            );
        });
    }
826599
protected function updatePermission()
    {
        foreach ($this->permissions() as $Permission) {
            $this->authManager->add($Permission);

            echo sprintf('    > permission `%s` added.', $Permission->name) . PHP_EOL;
        }
    }
1070348
public void setPermissions(UnsignedInteger32 permissions) {
		this.permissions = permissions;

		// Set the flag
		if (permissions != null) {
			flags |= SSH_FILEXFER_ATTR_PERMISSIONS;
		} else {
			flags ^= SSH_FILEXFER_ATTR_PERMISSIONS;
		}
	}
471372
public function permissions($model = NULL) {

        if(!$this->Auth->user()){
            $this->Flash->error(__('Please sign in'));
            $this->redirect(['action' => 'index']);
        }
        
        $this->model = $model;

        // Saving permissions
        if ($this->request->is('post') || $this->request->is('put')) {
            $perms = isset($this->request->data['Perms']) ? $this->request->data['Perms'] : array();
            foreach ($perms as $aco => $aros) {
                $action = str_replace(":", "/", $aco);
                foreach ($aros as $node => $perm) {
                    list($model, $id) = explode(':', $node);
                    $node = array('model' => $model, 'foreign_key' => $id);
                    if ($perm == 'allow') {
                        $this->Acl->allow($node, $action);
                    } elseif ($perm == 'inherit') {
                        $this->Acl->inherit($node, $action);
                    } elseif ($perm == 'deny') {
                        $this->Acl->deny($node, $action);
                    }
                }
            }
        }

        if (!$model || !in_array($model, Configure::read('AclManager.aros'))) {
            $m = Configure::read('AclManager.aros');
            $model = $m[0];
        }

        $Aro = $this->{$model};
        $arosRes = $this->paginate($Aro->alias());
        $aros = $this->_parseAros($arosRes);
        $permKeys = $this->_getKeys();

        /**
         * Build permissions info
         */
        $acosRes = $this->Acl->Aco->find('all', ['order' => 'lft ASC'])->contain(['Aros'])->toArray();
        $this->acos = $acos = $this->_parseAcos($acosRes);

        $perms = array();
        $parents = array();
        foreach ($acos as $key => $data) {
            $aco = & $acos[$key];
            $aco = array('Aco' => $data['Aco'], 'Aro' => $data['Aro'], 'Action' => array());
            $id = $aco['Aco']['id'];

            // Generate path
            if ($aco['Aco']['parent_id'] && isset($parents[$aco['Aco']['parent_id']])) {
                $parents[$id] = $parents[$aco['Aco']['parent_id']] . '/' . $aco['Aco']['alias'];
            } else {
                $parents[$id] = $aco['Aco']['alias'];
            }

            $aco['Action'] = $parents[$id];

            // Fetching permissions per ARO
            $acoNode = $aco['Action'];

            foreach ($aros as $aro) {
                $aroId = $aro[$Aro->alias()]['id'];
                $evaluate = $this->_evaluate_permissions($permKeys, array('id' => $aroId, 'alias' => $Aro->alias()), $aco, $key);
                $perms[str_replace('/', ':', $acoNode)][$Aro->alias() . ":" . $aroId . '-inherit'] = $evaluate['inherited'];
                $perms[str_replace('/', ':', $acoNode)][$Aro->alias() . ":" . $aroId] = $evaluate['allowed'];
            }
        }
        
        $this->request->data = array('Perms' => $perms);
        $this->set('model', $model);
        $this->set('manage', Configure::read('AclManager.aros'));
        $this->set('hideDenied', Configure::read('AclManager.hideDenied'));
        $this->set('aroAlias', $Aro->alias());
        $this->set('aroDisplayField', $Aro->displayField());
        $this->set(compact('acos', 'aros'));
    }
41971
protected function hasCorrectPermissionForUpdate() : bool
    {
        if (! $this->pathToUpdate) {
            throw new \Exception('No directory set for update. Please set the update with: setPathToUpdate(path).');
        }

        $collection = collect($this->pathToUpdate->files())->each(function ($file) { /* @var \SplFileInfo $file */
            if (! File::isWritable($file->getRealPath())) {
                event(new HasWrongPermissions($this));

                return false;
            }
        });

        return true;
    }
1086180
public function assignPermission($permissionId = null)
    {
        $permissions = $this->permissions;

        if (! $permissions->contains($permissionId)) {
            $this->permissions()->attach($permissionId);

            return true;
        }

        return false;
    }
336511
public function main()
    {
        $this->setup('propset');

        $this->log("Set svn property for '" . $this->getToDir() . "'");

        $output = $this->run([$this->getSvnPropertyName(), $this->getSvnPropertyValue(), $this->getToDir()]);
    }