permissions – / etc / sudoers is owned by gid 33, it should be 0, and when I try pkexec I get "failed authentication"

I was trying to access and write permissions on my apache sites-available folder through ssh / sftp. I really did not understand what I was doing to be honest and I executed the following commands:

$ sudo usermod -a -G www-data USER NAME
$ sudo chgrp -R www-data
$ sudo chmod -R g + w / etc /

After running these commands I can no longer connect through filezilla. When I try to use sudo I get the following:

sudo: / etc / sudoers is owned by gid 33, it must be 0
sudo: no valid sudoer sources found, stop smoking
sudo: the policy snap can not be initialized

I did some digging and I found that I should run pkexec visudo, but when I execute that and enter my password I get ==== FAILED AUTHENTICATION ===.

I'm at a loss and I'm not sure how to solve this problem. Obviously I broke something by changing the permissions of / etc /.

8 – How do you make a POST request from Guzzle with "Basic Authentication" for the current user?

I was able to find an alternative solution that solved my question. First, I had to allow "Anonymous" users the POST permission to my custom REST resource. This allowed my Guzzle resource to access my resource through POST programmatically.
In my REST resource, I am checking the user's permission, which restricts access for users without defined permissions (in my case, "access content").

/ **
* Provide a resource to obtain packages per entity.
*
* @RestResource (
* id = "distribution_content_ingestion",
* label = @Translation ("Ingestion of distribution content"),
* serialization_class = "Drupal  my_module  Normalizer  JsonDenormalizer",
* uri_paths = {
* "canonical" = "/ entity / distribution_ingest / {distribution_id}",
* "https://www.drupal.org/link-relations/create" = "/ entity / distribution_ingest / {distribution_id}"
*}
*)
* /
DistributionIngestResource class extends ResourceBase {
/ **
* A current user instance.
*
* @var  Drupal  Core  Session  AccountProxyInterface
* /
protected $ currentUser;

/ **
* Build a Drupal object  rest  Plugin  ResourceBase.
*
* @param array $ configuration
* A configuration matrix that contains information about the instance of the add-on.
* @param string $ plugin_id
* The plugin_id for the plugin instance.
* @param mixed $ plugin_definition
* The definition of plugin implementation.
* @param array $ serializer_formats
* The serialization formats available.
* @param  Psr  Log  LoggerInterface $ logger
* A logger instance.
* @param  Drupal  Core  Session  AccountProxyInterface $ current_user
* A current user instance.
* /
public function __constructed (
array $ configuration,
$ plugin_id,
$ plugin_definition,
array $ serializer_formats,
LoggerInterface $ logger,
AccountProxyInterface $ current_user) {
parent :: __ construct ($ configuration, $ plugin_id, $ plugin_definition, $ serializer_formats, $ logger);

$ this-> currentUser = $ current_user;
}

/ **
* {@inheritdoc}
* /
static public function create (ContainerInterface $ container, array $ configuration, $ plugin_id, $ plugin_definition) {
return new static (
$ configuration,
$ plugin_id,
$ plugin_definition,
$ container-> getParameter (& # 39; serializer.formats & # 39;),
$ container-> get (& # 39; logger.factory & # 39;) -> get (& # 39; rest & # 39;),
$ container-> get (& # 39; current_user & # 39;)
);
}

/ **
* Respond to POST requests.
*
* Returns a list of packages for the specified entity.
*
* @param string $ distribution_id
* The Distribution ID to be ingested.
* @param array $ data
* POST data.
*
* @return  Drupal  rest  ResourceResponse
* The expected exception is thrown.
* /
public function post ($ distribution_id, $ data) {
// You must implement the logic of your REST resource here.
// Use the current user after pass authentication to validate access.
if (! $ this-> currentUser-> hasPermission (& # 39; access content & # 39;)) {
launch new AccessDeniedHttpException ();
}

/ **
* Some code here.
* /
}
}