Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1847 connectés 

  FORUM HardWare.fr
  Linux et OS Alternatifs
  Divers

  [RESOLU]Problème de droits d'écriture pour Apache sous CentOS

 

Sujet(s) à lire :
 

 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[RESOLU]Problème de droits d'écriture pour Apache sous CentOS

n°1445919
nixnbk
Strip the flesh salt the wound
Posté le 26-03-2020 à 09:12:49  profilanswer
 

Bonjour,
 
J'ai créé un sujet dans la cat PHP mais je ne suis pas sur d'avoir mis ça au bon endroit : https://forum.hardware.fr/hfr/Progr [...] 7623_1.htm
En gros j'ai installé apache sous centos, et l'appli web que j'ai déployé doit à un moment donné permettre visiblement à Apache d'écrire dans certains répertoires (pour télécharger des images notamment).
 
Il ya une page PHP de test, et visiblement les tests sont invalidés. Ce que je ne comprends pas c'est que normalement au vu des droits appliqués ça devrait fonctionner. Une idée d'où ça pourrait venir  ?
 
Je remet l'autre sujet en citation ici :  

Citation :

Hello à tous,  
 
Tout d'abord j'espère être dans la bonne catégorie.
 
Je suis en train de tester la mise en place d'un serveur opendcim (https://www.opendcim.org/) en version 19.10 sous CentOS.
J'ai suivi le wiki mis à dispo par les devs (https://wiki.opendcim.org/wiki/index.php/Installation), à une vache près qu'il faut effectuer l'étape Enable User Authentication après avoir installé les fichiers opendcim.
 
Bref, le site fonctionne mais j'ai un léger souci de droits lors de l'affichage d'une page php https://opendcim/rightscheck.php :  
https://i.postimg.cc/P5kHB4K4/Screen-Shot-03-25-20-at-05-42-PM.png
D'après le script php, il effectue un test d'écriture dans les répertoires du site... Normalement au vu des droits affecter ça devrait fonctionner, mais visiblement non, il continue de me dire que c'est pas bon.
Apparemment il exécute le script en tant que user Apache.
J'ai même fait un test en passant les répertoires en 777, rien n'y fait.
 
A moins que le fichier rightscheck.php soit daubé mais ça me surprendrait :  

<!doctype html>
<html>
<head>
<title>openDCIM rights check</title>
<style type="text/css">
.wanted { background-color: forestgreen; }
.warning { background-color: orange; }
table { background-color: azure; border-collapse: collapse; border: 1px solid black; display: inline-flex; }
td, th { padding: 0 8px; }
</style>
</head>
<body>
 
<?php
 
$userid=exec('id -u');
$grpid=exec('id -g');
 
// The directories we want writable for uploads
$wantedpaths=array('drawings', 'pictures','vendor'.DIRECTORY_SEPARATOR.'mpdf'.DIRECTORY_SEPARATOR.'mpdf'.DIRECTORY_SEPARATOR.'ttfontdata');
 
print "<table>
 <tr>
  <th>Directory</th>
  <th>Writable</th>
  <th colspan=2>Rights</th>
  <th>Owner:Group</th>
 </tr>";
function matches(&$check,$const){
 if($check==$const){
  $check="<font color=\"LimeGreen\">$check</font>";
 }
}
 
function printrow($file,&$wantedpaths,$userid,$grpid){
 $uploadDir=$file;
 $not=(is_writable('.'.DIRECTORY_SEPARATOR.$uploadDir))?'<font color="LimeGreen">Yes</font>':'<font color="red">No</font>';
 $perms = fileperms('.'.DIRECTORY_SEPARATOR.$uploadDir);
 
 if (($perms & 0xC000) == 0xC000) {
  // Socket
  $info = 's';
 } elseif (($perms & 0xA000) == 0xA000) {
  // Symbolic Link
  $info = 'l';
 } elseif (($perms & 0x8000) == 0x8000) {
  // Regular
  $info = '-';
 } elseif (($perms & 0x6000) == 0x6000) {
  // Block special
  $info = 'b';
 } elseif (($perms & 0x4000) == 0x4000) {
  // Directory
  $info = 'd';
 } elseif (($perms & 0x2000) == 0x2000) {
  // Character special
  $info = 'c';
 } elseif (($perms & 0x1000) == 0x1000) {
  // FIFO pipe
  $info = 'p';
 } else {
  // Unknown
  $info = 'u';
 }
 
 // Owner
 $info .= (($perms & 0x0100) ? 'r' : '-');
 $info .= (($perms & 0x0080) ? 'w' : '-');
 $info .= (($perms & 0x0040) ?
    (($perms & 0x0800) ? 's' : 'x' ) :
    (($perms & 0x0800) ? 'S' : '-'));
 
 // Group
 $info .= (($perms & 0x0020) ? 'r' : '-');
 $info .= (($perms & 0x0010) ? 'w' : '-');
 $info .= (($perms & 0x0008) ?
    (($perms & 0x0400) ? 's' : 'x' ) :
    (($perms & 0x0400) ? 'S' : '-'));
 
 // World
 $info .= (($perms & 0x0004) ? 'r' : '-');
 $info .= (($perms & 0x0002) ? 'w' : '-');
 $info .= (($perms & 0x0001) ?
    (($perms & 0x0200) ? 't' : 'x' ) :
    (($perms & 0x0200) ? 'T' : '-'));
 
 $owner=fileowner($uploadDir);
 $group=filegroup($uploadDir);
 $perms=substr(sprintf('%o', $perms), -4);
 matches($owner,$userid);
 matches($group,$grpid);
 
 $class=(in_array($uploadDir,$wantedpaths))?' class="wanted"':'';
 $class=(preg_match('/LimeGreen/',$not) && !in_array($uploadDir,$wantedpaths))?' class="warning"':$class;
 
 print "\n\t<tr$class>\n\t\t<td>$uploadDir</td><td>$not</td><td>$info</td><td>$perms</td><td>$owner:$group</td></tr>";
}
 
$directory=".";
$scanned_directory = array_diff(scandir($directory), array('..', '.'));
foreach($scanned_directory as $i => $file){
 if(!is_dir($file)){
  continue;
 }
 
 printrow($file,$wantedpaths,$userid,$grpid);
}
 
# Add in extra paths here that aren't part of the root loop.
printrow('vendor'.DIRECTORY_SEPARATOR.'mpdf'.DIRECTORY_SEPARATOR.'mpdf'.DIRECTORY_SEPARATOR.'ttfontdata',$wantedpaths,$userid,$grpid);
 
# Handle paths that may or may not be set in the configuration screen for docker
# clowns.
if(file_exists("db.inc.php" )){
 require_once("db.inc.php" );
 foreach($config->ParameterArray as $option => $value){
  if(preg_match('/path$/',$option)){
   array_push($wantedpaths,$value);
   printrow($value,$wantedpaths,$userid,$grpid);
  }
 }
}
 
print "\n</table>
<table>
 <tr>
  <th>Legend</th>
 </tr>
 <tr class=\"wanted\"><td>Directory that should be writable</td></tr>
 <tr class=\"warning\"><td>Directory is writable and unexpected</td></tr>
 <tr><td>Normal and expected rights</td></tr>
</table>
<p>Script is being executed as owner: $userid group: $grpid</p>";
 


 
Bref si vous avez une idée de pourquoi ça fonctionne pas ça m'intéresse.
Est-ce que ça pourrait venir du package complet qui fonctionnerait pas bien sous CentOS (j'ai l'impression que les devs tournent plutôt sur du noyau debian/ubuntu) ?


Message édité par nixnbk le 26-03-2020 à 10:36:29

---------------
I'll feed your skin snacks to my cockatiel!
mood
Publicité
Posté le 26-03-2020 à 09:12:49  profilanswer
 

n°1445924
nixnbk
Strip the flesh salt the wound
Posté le 26-03-2020 à 10:35:54  profilanswer
 

Problème réglé, c'était SELinux qui n'autorisait pas à Apache d'écrire dans les dits répertoires.


---------------
I'll feed your skin snacks to my cockatiel!

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Linux et OS Alternatifs
  Divers

  [RESOLU]Problème de droits d'écriture pour Apache sous CentOS

 

Sujets relatifs
[RESOLU] Un problème que je n'arrive pas à régler sur postfix.[DEBIAN] Problème de nginx avec Lemonldap
Apache, user applicatif et SSHproblème execution script python avec crontab
[Manjaro] Problème xorg.conf VIDE [RÉSOLU]Xubuntu droits utilisateurs non respectés
Problème Permission denied sous OMVProbleme Installation OMV cartes reseau
Probléme connexion session graphiqueProblème PFSENSE
Plus de sujets relatifs à : [RESOLU]Problème de droits d'écriture pour Apache sous CentOS


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR