Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

tester une authentification

5 réponses
Avatar
unbewusst
gr=E2ce =E0 une note d'application Apple, j'ai une petite appli qui
authentifie et autorise un utilisateur s'il est admin.

pour l'instant cette appli basique affiche "Auth correct" sur un
NSTextFieldet c'est tout, je voudrais tester =E7a "en vraie grandeur"
c=E0d, apr=E8s avoir obtenu aunthentification et autorisation, lancer, par
exemple, un script que je lancerait autrement au terminal par sudo.

mon but pr=E9cis et de pouvoir lancer depuis une appli RubyCocoa un
script utilisant rsync sous les droits d'admin.

j'ai bien compris qu'il fallait scinder en 2 l'appli :

- disons la partie UI qui n'a pas besoin d'admin ;
- la partie action effective qui se fait sous admin.

ce que je ne vois pas c'est comme se lance la partie action une fois
les droits obtenus.

en pratique, qu'est-ce qui remplace le "sudo" de command line ???

Yvon

5 réponses

Avatar
Patrick Stadelmann
In article ,
unbewusst wrote:

j'ai bien compris qu'il fallait scinder en 2 l'appli :

- disons la partie UI qui n'a pas besoin d'admin ;
- la partie action effective qui se fait sous admin.

ce que je ne vois pas c'est comme se lance la partie action une fois
les droits obtenus.


<http://developer.apple.com/documentation/Security/Conceptual/authorizati
on_concepts/index.html#//apple_ref/doc/uid/TP30000995>

Patrick
--
Patrick Stadelmann

Avatar
unbewusst
On 3 sep, 10:46, Patrick Stadelmann
wrote:
In article ,

unbewusst wrote:
j'ai bien compris qu'il fallait scinder en 2 l'appli :

- disons la partie UI qui n'a pas besoin d'admin ;
- la partie action effective qui se fait sous admin.

ce que je ne vois pas c'est comme se lance la partie action une fois
les droits obtenus.


<http://developer.apple.com/documentation/Security/Conceptual/authorizati
on_concepts/index.html#//apple_ref/doc/uid/TP30000995>

Patrick
--
Patrick Stadelmann


ok, merci beaucoup, j'ai lu ça, enfin parcouru en diagonale, trop peut-
être...

pour l'instant pour tester le fameux exemple Apple "AuthForAll" j'ai
fait un bête :

system( "/usr/libexec/locate.updatedb" )

et là à "console.log" ça couine ;-) :

/.Spotlight-V100: Permission denied
find: /.Trashes: Permission denied
find: /Applications/Utilities/PureFTPd-Manager/PureFTPd Manager.app/
Contents/Frameworks/SMySQL_bundled.framework/Versions/A/Resources/
English.lproj/MCPConnectionWindow.nib: Permission denied
find: /Library/Logs/Console/0: Permission denied
[...]
find: /opt/local/var/db/dports/build/
_opt_local_var_db_dports_sources_rsync.rsync.darwinports.org_dpupdate_dport s_x11_rxvt-
unicode/work/rxvt-unicode-8.1: Permission denied
[...]
find: /private/etc/cups/certs: Permission denied
[...]
find: /private/var/vm/app_profile: Permission denied
find: /System/Library/User Template/da.lproj/Desktop: Permission
denied
[...]
find: /System/Library/User Template/zh_TW.lproj/Public/Drop Box:
Permission denied
[...]
find: /Users/anais/Public/Drop Box: Permission denied
csh: /var/db/locate.database: Permission denied.

et comme je me doute que vu ce résultat ne je ne suis pas sudoer avec
l'autorisation de "AuthForAll" j'ai essayé un autre truc avec un
script zsh qui vérifie si je suis sudoer quand je le lance :

-------------------------------------------------------
#! /usr/bin/env zsh

DIR=${0:h}
SUDOER="${DIR}/SUDOER.txt"
NOT_SUDOER="${DIR}/NOT_SUDOER.txt"

if [[ -e $SUDOER ]] then
rm -rf "${SUDOER}"
fi

if [[ -e $NOT_SUDOER ]] then
rm -rf "${NOT_SUDOER}"
fi

[ "$SUDO_USER" -a `id -u` -eq 0 ] || {
touch "${NOT_SUDOER}"
exit 1
}
touch "${SUDOER}"
exit 0
-------------------------------------------------------

donc ce script crée sur le bureau un fichier texte vide
"NOT_SUDOER.txt" si je ne suis pas sudoer en le lançant et un fichier
"SUDOER.txt" si je le suis.

résultat de la manip : je ne le suis pas...

en fait mon problème est d'obtenir les droits admin pour un rsync, ma
petite appli permettra de synchroniser des répertoires utilisateurs
vers une clé usb.

c'est un peu comme CarbonCopyCloner, et dans certains cas, il faut les
droits admin pour copier, synchroniser, les fichiers admin ( j'en ai
qq'uns dans mon répertoire ~/bin) ...

bon en tk je relirai cette note + attentivement...

pour le reste l'exemple donné par apple marche bien car j'ai vérivié
mon /etc/authorization, j'ai bien les nouveaux droits :

<key>com.apple.dts.AuthForAll.Alpha</key>
<dict>
<key>default-prompt</key>
<dict>
<key></key>
<string>YOU MUST BE AUTHORIZED TO DO ALPHA</string>
<key>en</key>
<string>You must be authorized to do alpha.</string>
<key>en_AU</key>
<string>Strewth! You must be authorised to do alpha.</string>
</dict>
<key>rule</key>
<string>allow</string>
</dict>
<key>com.apple.dts.AuthForAll.Beta</key>
<dict>
<key>default-prompt</key>
<dict>
<key></key>
<string>YOU MUST BE AUTHORIZED TO DO BETA</string>
<key>en</key>
<string>You must be authorized to do beta.</string>
<key>en_AU</key>
<string>Strewth! You must be authorised to do beta.</string>
</dict>
<key>rule</key>
<string>authenticate-admin</string>
</dict>

me reste a mieux piger comment lancer la partie spécifique, liée à
rsync et nécessitant des droits admin, de mon code.

je pense en faire un petit module pour RubyCocoa...

merci encore !

Yvon


Avatar
Patrick Stadelmann
In article ,
unbewusst wrote:

pour l'instant pour tester le fameux exemple Apple "AuthForAll" j'ai
fait un bête :

system( "/usr/libexec/locate.updatedb" )


Voir
<http://developer.apple.com/documentation/Security/Conceptual/authorizati
on_concepts/03authtasks/chapter_3_section_4.html#//apple_ref/doc/uid/TP30
000995-CH206-TPXREF33>

Ca donne bien "root" après authentification.

Patrick
--
Patrick Stadelmann

Avatar
unbewusst
On 3 sep, 17:57, Patrick Stadelmann
wrote:
In article ,

unbewusst wrote:
pour l'instant pour tester le fameux exemple Apple "AuthForAll" j'ai
fait un bête :

system( "/usr/libexec/locate.updatedb" )


Voir
<http://developer.apple.com/documentation/Security/Conceptual/authorizati
on_concepts/03authtasks/chapter_3_section_4.html#//apple_ref/doc/uid/TP30
000995-CH206-TPXREF33>

Ca donne bien "root" après authentification.

Patrick
--
Patrick Stadelmann



bon, ok, c'est peut-être alors le fait de passer, dans mon essai, par
system et des strings qui casse tout ???

merci en tout cas


Avatar
unbewusst
On 3 sep, 17:57, Patrick Stadelmann
wrote:
In article ,

unbewusst wrote:
pour l'instant pour tester le fameux exemple Apple "AuthForAll" j'ai
fait un bête :

system( "/usr/libexec/locate.updatedb" )


Voir
<http://developer.apple.com/documentation/Security/Conceptual/authorizati
on_concepts/03authtasks/chapter_3_section_4.html#//apple_ref/doc/uid/TP30
000995-CH206-TPXREF33>

Ca donne bien "root" après authentification.

Patrick
--
Patrick Stadelmann



c'est très exactement ce qu'il me manquait, maintenant ça marche
super :
Console.log:
Sep 3 21:44:05 www authexec: executing /usr/libexec/locate.updatedb

~/work/C/Cext2Ruby/ROSXAuth/C%> ps -Axu | grep locate.updatedb
yt 128 3.6 0.1 27416 436 p1 R+ 9:46PM 0:00.01
grep locate.updatedb
root 115 0.0 0.1 31916 784 ?? S 9:44PM 0:00.09 /
bin/csh -f /usr/libexec/locate.updatedb
root 118 0.0 0.0 31916 348 ?? S 9:44PM 0:00.01 /
bin/csh -f /usr/libexec/locate.updatedb


marche aussi en command line...

ce qui me manquait était juste la ligne :

cStatus = executeWithPrivileges( myFlags, &myAuthorizationRef,
&myToolPath, myArguments, bufferOut );

Merci beaucoup !