Master 1 ère année Sécurité des Systèmes Informatique 1 X Window Système graphique  X-Window, développé au MIT dans le cadre du projet Athena  Développement.

Slides:



Advertisements
Présentations similaires
Formation - Fedora et VMware
Advertisements

Programmation Tcl/Tk Raymond Ripp février 2012 Survol général
M2: Les parefeux Université Paris II & LRI Michel de Rougemont 1.Quest ce quun parefeu ? 2.Architecture des parefeux.
Raymond Ripp 5 mars 2013 la deuxième partie sera pour le 12 mars
UNIX Pour débutant. Applications En directNavigateurCourrierMode consoleFenêtrage http smtp ssh X protocoles - langages de programmation protocoles -
Programmation Tcl/Tk Raymond Ripp février 2010 Survol général o Applications et Protocoles o Windows Linux o Disques Processeurs o Passage en mode console.
Programmation Tcl/Tk Raymond Ripp février 2011 Survol général o Applications et Protocoles o Windows Linux o Disques Processeurs o Passage en mode console.
Programmation Tcl/Tk Raymond Ripp février 2011 Survol général o Applications et Protocoles o Windows Linux o Disques Processeurs o Passage en mode console.
Programmation Tcl Raymond Ripp 7 février 2012 deuxième partie du 14 février dans ce même ppt Survol général o Applications et Protocoles o Windows Linux.
Cours MIAGE « Architectures Orientées Services » Henry Boccon-Gibod 1 Architectures Orientées Services Composants de Service Exemple pratique de développement.
Status report SOLEIL April 2008
interface graphique permettant de faciliter la conception de topologies réseaux complexes Logiciel permettant de créer des machines virtuelles sur une.
Guillaume KRUMULA présente Exposés Système et Réseaux IR3 Mardi 5 Février 2008.
Formation TRANSFER Vietnam Mars 2003 Jean Pierre TO.
PILOTE - Sous Projet PILOTE SOUS-PROJET 5 Cyril Carrez, Elie Najm, Alexandre Tauveron.
Installation sous Windows
1 AWAP : Administrable Wireless Access Point Projet de fin détude 2003 Cédric Logeais Mathias Faure.
Symfony Formulaires.
FLSI602 Génie Informatique et Réseaux
TP de mise en oeuvre d’une PKI avec Openssl
Méthodes alternatives
Minimisation Techniques 1 Assimilation Algorithms: Minimisation Techniques Yannick Trémolet ECMWF Data Assimilation Training Course March 2006.
JDBC: manipuler une base de données en Java IFT6800 – E 2007 Jian-Yun Nie.
Les entrées /sorties en Java François Bonneville
Français I Leçon 2B Une semaine au lycée Au Debut #7 (for the dates of November 5 and 6) Please Translate the Following: 1. I love the math course. (Adorer.
Page 1 Introduction à ATEasy 3.0 Page 2 Quest ce quATEasy 3.0? n Ensemble de développement très simple demploi n Conçu pour développer des bancs de test.
10 Copyright © Oracle Corporation, Tous droits réservés. Autres concepts relatifs aux déclencheurs.
TM.
Scanning.
© 2007 P. Van Roy. All rights reserved. 1 FSAB1402: Informatique 2 La Concurrence Déclarative Peter Van Roy Département dIngénierie Informatique, UCL
CLUB DES UTILISATEURS SAS DE QUÉBEC
Serveurs Partagés Oracle
Python Interfaces graphiques
Ecole Supérieure Privée de ingénierie et de technologie année universitaire :2013/2014 Cross-Plateform Cours JavaScript.
IFT313 Introduction aux langages formels
Magnets fiche projet / project sheet IAFACTORY THE MAGNETIC FACTORY magnets. IAFACTORY | conseil en architecture de linformation | |
TortoiseSVN N°. Subversion : pour quoi faire ? Avoir un espace de stockage commun – Tous les étudiants du SIGLIS ont un espace svn commun Partager vos.
F Copyright © Oracle Corporation, Tous droits réservés. Créer des programmes avec Procedure Builder.
EPID-CPI-ISAIP Philippe Bancquart - mise à jour 24/02/ page 1 Liste des commandes DOS AT Schedules commands and programs to run on a computer. ATTRIB.
5.1 URDL22005 Systèmes dexploitation Threads Vue dEnsemble Modèles de Multithreading Problèmes des Threads Pthreads Threads Windows XP Threads Linux Threads.
Authentification LDAP
EPID-CPI-ISAIP Philippe Bancquart - mise à jour 24/02/ page 1 Procédures stockées CPI-SQLServer.
Développer en C avec Eclipse Introduction Création d'un projet Ajout de fichiers Compilation Exécution Utiliser le débogueur Département dinformatique.
PLSQL ORACLE 8i Connecter VB à BD Oracle Les collections Question de révision Les blocs anonymes Les triggers REVISION Par : Joël Huot.
1 GPA435 Systèmes dexploitation et programmation de système Copyright, 2000 © Tony Wong, Ph.D., ing. Chapitre 4 Syntaxe des commandes, documentation standard,
1 GPA435 Systèmes dexploitation et programmation de système Copyright, 2000 © Tony Wong, Ph.D. Chapitre 9 Exemples de programmation Bourne shell et nawk(1)
1 CSI 2532 Lab5 Installation de JDBC Février 13, 2012.
PHP GTK PHP…au delà du Web Paris, 28 novembre 2001 Armel FAUVEAU GLOBALIS media systems.
Multi-Thread Jian-Yun Nie
CSI2520 Le langage Scheme (2) Un langage de programmation fonctionnelle.
Sécurité Informatique Module 05
Utilisation avancée de linux
Master 1 ère année Sécurité des Systèmes Informatique 1 L'initialisation Linux  Basée sur le modèle System V  Démarrage des scripts grâce a init  La.

Sécurité des Systèmes Informatique
UTILISATION DE LINUX. LINUX 2 UTILISATION DE LINUX Différences Windows-Linux Le prix La licence Le choix des distributions Les applications Les utilisateurs.
Gérer la sécurité des mots de passe et les ressources
Mise à jour des Fichiers Redo Log
1 Algorithmique et programmation en février - juin 2007 ORSAY.
VPN sous Linux Essaka Cynthia Serbin Laurent. Sommaire  Introduction  Vpnd  LRP  Freeswan.
Utilisation avancée de linux Réseau Démarrage et arrêt.
Logs, backup, maintenance
PLAN Correction du RUSH 3
Elaboré par Ahmed BESSAIDI
Master 1ère année Sécurité des Systèmes d’Information 1 Programmation en shell.
LPI 101 : GNU & Commandes UNIX Installer & Configurer X11  XF86Setup  xf86Config  Xvidtune  /etc/X11/XF86Config  /etc/X11/xorg.conf  Xresources.
Déjouer les pièges du Dockerfile
Top right corner for field-mark, customer or partner logotypes. See Best practice for example. Slide title 40 pt Slide subtitle 24 pt Text 24 pt Bullets.
1-1 Introduction to ArcGIS Introductions Who are you? Any GIS background? What do you want to get out of the class?
POWERPOINT PRESENTATION FOR INTRODUCTION TO THE USE OF SPSS SOFTWARE FOR STATISTICAL ANALISYS BY AMINOU Faozyath UIL/PG2018/1866 JANUARY 2019.
Transcription de la présentation:

Master 1 ère année Sécurité des Systèmes Informatique 1 X Window Système graphique  X-Window, développé au MIT dans le cadre du projet Athena  Développement par Sun du système NeWS (Network Windowing System) NeWS étant un système propriétaire de Sun basé sur PostScript d'Adobe alors que X était entièrement libre, c'est ce dernier qui s'est imposé en se propageant rapidement dans le monde Unix, et en particulier dans les universités.  X-Window, développé au MIT dans le cadre du projet Athena  Développement par Sun du système NeWS (Network Windowing System) NeWS étant un système propriétaire de Sun basé sur PostScript d'Adobe alors que X était entièrement libre, c'est ce dernier qui s'est imposé en se propageant rapidement dans le monde Unix, et en particulier dans les universités.

Master 1 ère année Sécurité des Systèmes Informatique 2 X Window Système graphique  X-Window du MIT (notez l'absence de "s" à Window, au contraire des produits propriétaires, comme Windows 95, OpenWindows, DECWindows), c'est:  avant tout, un protocole d'affichage graphique de très bas niveau, c'est-à- dire avec des primitives simples  une plateforme software (serveur) permettant cet affichage interactif sur un ensemble restreint de plateformes hardware (en principe, écran, clavier et souris à 3 boutons)  Xlib, l'ensemble de fonctions de base à disposition des clients  le toolkit "Xt Intrinsics", ensemble de fonctions de gestion de widgets  les widgets Athena standards (Xaw)  un "window manager" (twm), tout aussi standard, mais offrant un "look" un peu simple  un ensemble d'applications clientes: xterm, xedit, xman, xclock…  un ensemble de fichiers de configuration par défaut (.Xresources...) à l'usage de twm et des applications.  X-Window du MIT (notez l'absence de "s" à Window, au contraire des produits propriétaires, comme Windows 95, OpenWindows, DECWindows), c'est:  avant tout, un protocole d'affichage graphique de très bas niveau, c'est-à- dire avec des primitives simples  une plateforme software (serveur) permettant cet affichage interactif sur un ensemble restreint de plateformes hardware (en principe, écran, clavier et souris à 3 boutons)  Xlib, l'ensemble de fonctions de base à disposition des clients  le toolkit "Xt Intrinsics", ensemble de fonctions de gestion de widgets  les widgets Athena standards (Xaw)  un "window manager" (twm), tout aussi standard, mais offrant un "look" un peu simple  un ensemble d'applications clientes: xterm, xedit, xman, xclock…  un ensemble de fichiers de configuration par défaut (.Xresources...) à l'usage de twm et des applications.

Master 1 ère année Sécurité des Systèmes Informatique 3 X Window Qu’est-ce que X?  Environnement graphique basé sur un modèle client-serveur  Le service affiche l’écran et gère les entrées utilisateur (souris, clavier, etc…)  Le client est un programme qui utilise l’affichage graphique  X possède son propre protocole réseau # grep X /etc/services | grep 6000 x /tcp X # the X Window System  La version utilisée est X11R6  Environnement graphique basé sur un modèle client-serveur  Le service affiche l’écran et gère les entrées utilisateur (souris, clavier, etc…)  Le client est un programme qui utilise l’affichage graphique  X possède son propre protocole réseau # grep X /etc/services | grep 6000 x /tcp X # the X Window System  La version utilisée est X11R6

Master 1 ère année Sécurité des Systèmes Informatique 4 X Window Bibliothèques  Bibliothèques qui gèrent l’affichage  Xlibaccès de base  Boîtes à outils (widgets)  XawAthena  OpenLookSun  Motif  QtK Desktop Environment (KDE)  GtkGIMP ToolKit de GNU Network Object Model Environment (GNOME)  Bibliothèques qui gèrent l’affichage  Xlibaccès de base  Boîtes à outils (widgets)  XawAthena  OpenLookSun  Motif  QtK Desktop Environment (KDE)  GtkGIMP ToolKit de GNU Network Object Model Environment (GNOME)

Master 1 ère année Sécurité des Systèmes Informatique 5 X Window Bibliothèques  Implémentations du standard X dans les distributions Linux  XFree86Ancien standard  XorgNouveau standard  Les deux implémentations offrent les mêmes services.  Implémentations du standard X dans les distributions Linux  XFree86Ancien standard  XorgNouveau standard  Les deux implémentations offrent les mêmes services.

Master 1 ère année Sécurité des Systèmes Informatique 6 X Window Configuration  xorgcfgoutil de configuration  Dans les distributions Red Hat, xorgcfg est remplacé par system- config-display  xorgcfgoutil de configuration  Dans les distributions Red Hat, xorgcfg est remplacé par system- config-display

Master 1 ère année Sécurité des Systèmes Informatique 7 X Window Fichier de configuration  Le fichier /etc/X11/xorg.conf  Attention! Faire une sauvegarde de ce fichier avant toute modification  Le fichier /etc/X11/xorg.conf  Attention! Faire une sauvegarde de ce fichier avant toute modification

Master 1 ère année Sécurité des Systèmes Informatique 8 X Window Serveur de polices de caractères  X Window propose un processus serveur de polices de caractères # service xfs status xfs (pid 2182) en cours d'exécution...GNOME  Configuration # more /etc/X11/fs/config # # Default font server configuration file for Red Hat Linux # # allow a max of 10 clients to connect to this font server client-limit = 10 # when a font server reaches its limit, start up a new one clone-self = on # where to look for fonts # catalogue = /usr/X11R6/lib/X11/fonts/korean, /usr/X11R6/lib/X11/fonts/misc:unscaled, /usr/X11R6/lib/X11/fonts/75dpi:unscaled,  X Window propose un processus serveur de polices de caractères # service xfs status xfs (pid 2182) en cours d'exécution...GNOME  Configuration # more /etc/X11/fs/config # # Default font server configuration file for Red Hat Linux # # allow a max of 10 clients to connect to this font server client-limit = 10 # when a font server reaches its limit, start up a new one clone-self = on # where to look for fonts # catalogue = /usr/X11R6/lib/X11/fonts/korean, /usr/X11R6/lib/X11/fonts/misc:unscaled, /usr/X11R6/lib/X11/fonts/75dpi:unscaled,

Master 1 ère année Sécurité des Systèmes Informatique 9 X Window Serveur de polices de caractères  Des polices peuvent être ajoutées  Par exemple Xorg, FreeType et TrueType  Vérifier si les chemins dans le fichier de configuration  xfontsel  Des polices peuvent être ajoutées  Par exemple Xorg, FreeType et TrueType  Vérifier si les chemins dans le fichier de configuration  xfontsel

Master 1 ère année Sécurité des Systèmes Informatique 10 X Window Environnements graphiques  Les gestionnaires d’affichage (Display Manager) sont des clients X qui affichent un cartouche de connexion  gdmGNOME  kdmKDE  xdm  Le gestionnaire d’affichage distributions Red Hat, xorgcfg a été remplacé par system-config-display # grep initdefault /etc/inittab # 0 - halt (Do NOT set initdefault to this) # 6 - reboot (Do NOT set initdefault to this) id:5:initdefault:  Les gestionnaires d’affichage (Display Manager) sont des clients X qui affichent un cartouche de connexion  gdmGNOME  kdmKDE  xdm  Le gestionnaire d’affichage distributions Red Hat, xorgcfg a été remplacé par system-config-display # grep initdefault /etc/inittab # 0 - halt (Do NOT set initdefault to this) # 6 - reboot (Do NOT set initdefault to this) id:5:initdefault:

Master 1 ère année Sécurité des Systèmes Informatique 11 X Window Environnements graphiques  Avec le niveau d’init 5 /etc/X11/prefdm est exécuté # grep prefdm /etc/inittab x:5:respawn:/etc/X11/prefdm -nodaemon  Le script /etc/X11/prefdm lit le fichier /etc/sysconfig/desktop # more /etc/sysconfig/desktop DESKTOP="GNOME"  Avec le niveau d’init 5 /etc/X11/prefdm est exécuté # grep prefdm /etc/inittab x:5:respawn:/etc/X11/prefdm -nodaemon  Le script /etc/X11/prefdm lit le fichier /etc/sysconfig/desktop # more /etc/sysconfig/desktop DESKTOP="GNOME"

Master 1 ère année Sécurité des Systèmes Informatique 12 X Window Configuration du gestionnaire d’affichage  GNOME /etc/X11/gdm/gdm.conf  KDE /usr/share/config/kdm/kdmrc  XDM /usr/X11R6/lib/X11/xdm/xdm- config  Le répertoire peut être différent en fonction de la distribution  GNOME /etc/X11/gdm/gdm.conf  KDE /usr/share/config/kdm/kdmrc  XDM /usr/X11R6/lib/X11/xdm/xdm- config  Le répertoire peut être différent en fonction de la distribution

Master 1 ère année Sécurité des Systèmes Informatique 13 X Window Contrôle de plusieurs écrans  X Window peut contrôler plusieurs écrans  Les écrans se nomment  :0.0  :0.1  X Window peut contrôler plusieurs écrans  Les écrans se nomment  :0.0  :0.1

Master 1 ère année Sécurité des Systèmes Informatique 14 X Window Prise de contrôle à distance  rshremote shell  rlogin  telnet  ssh  ssh  ssh –X  rshremote shell  rlogin  telnet  ssh  ssh  ssh –X

Master 1 ère année Sécurité des Systèmes Informatique 15 X Window Scripts d’administration  Tcl/Tk  Tcl Tool Command Language  TKTool Kit  Tcl/Tk  Tcl Tool Command Language  TKTool Kit

Master 1 ère année Sécurité des Systèmes Informatique 16 X Window Exemple Tcl/Tk

Master 1 ère année Sécurité des Systèmes Informatique 17 X Window Exemple Tcl/Tk #!/usr/bin/wish # nagios-ws.sh GUI (Graphic User Interface). # Creation date: jeu jan 25 09:32:17 CET 2007 # # Set window title wm title. "Ajouter et supprimer une machine" # Default values set realdir /root/nagios/bin set machinename poste12 set parentname switch1 set backupdir /data/backup # Recherche du site set fqdn [exec hostname -a] set host [exec hostname] set domaine [string trimleft $fqdn $host] # First frame : parameter fields frame.first -borderwidth 10 pack.first -side top -fill x label.first.machinelabel -text "Nom de la machine:" -padx 0 entry.first.srvname -width 12 -relief sunken -justify right -textvariable machinename label.first.domainlabel -text "$domaine" -padx 0 label.first.plabel -text " Nom du parent:" -padx 0 entry.first.pname -width 12 -relief sunken -justify right -textvariable parentname label.first.domainlabel2 -text "$domaine" -padx 0 pack.first.machinelabel.first.srvname.first.domainlabel -side left pack.first.plabel.first.pname.first.domainlabel2 -side left #!/usr/bin/wish # nagios-ws.sh GUI (Graphic User Interface). # Creation date: jeu jan 25 09:32:17 CET 2007 # # Set window title wm title. "Ajouter et supprimer une machine" # Default values set realdir /root/nagios/bin set machinename poste12 set parentname switch1 set backupdir /data/backup # Recherche du site set fqdn [exec hostname -a] set host [exec hostname] set domaine [string trimleft $fqdn $host] # First frame : parameter fields frame.first -borderwidth 10 pack.first -side top -fill x label.first.machinelabel -text "Nom de la machine:" -padx 0 entry.first.srvname -width 12 -relief sunken -justify right -textvariable machinename label.first.domainlabel -text "$domaine" -padx 0 label.first.plabel -text " Nom du parent:" -padx 0 entry.first.pname -width 12 -relief sunken -justify right -textvariable parentname label.first.domainlabel2 -text "$domaine" -padx 0 pack.first.machinelabel.first.srvname.first.domainlabel -side left pack.first.plabel.first.pname.first.domainlabel2 -side left

Master 1 ère année Sécurité des Systèmes Informatique 18 X Window Exemple Tcl/Tk # Create a frame for buttons and entry. frame.second -borderwidth 10 pack.second -side top -fill x # Create the command buttons. label.second.commandlabel -text "Commandes:" -padx 0 button.second.add -text "Ajouter" -command Add button.second.remove -text "Supprimer" -command Remove button.second.check -text "Vérifier" -command Check button.second.restart -text "Redémarrer" -command Restart pack.second.commandlabel.second.add.second.remove.second.check.second.restart -side left button.second.help -text "Aide" -command Help button.second.quit -text "Quitter" -command exit pack.second.quit.second.help -side right # Create a text widget to log the output frame.t set log [text.t.log -width 80 -height 40 \ -borderwidth 2 -relief raised -setgrid true \ -yscrollcommand {.t.scroll set}] scrollbar.t.scroll -command {.t.log yview} pack.t.scroll -side right -fill y pack.t.log -side left -fill both -expand true pack.t -side top -fill both -expand true # Create a frame for buttons and entry. frame.second -borderwidth 10 pack.second -side top -fill x # Create the command buttons. label.second.commandlabel -text "Commandes:" -padx 0 button.second.add -text "Ajouter" -command Add button.second.remove -text "Supprimer" -command Remove button.second.check -text "Vérifier" -command Check button.second.restart -text "Redémarrer" -command Restart pack.second.commandlabel.second.add.second.remove.second.check.second.restart -side left button.second.help -text "Aide" -command Help button.second.quit -text "Quitter" -command exit pack.second.quit.second.help -side right # Create a text widget to log the output frame.t set log [text.t.log -width 80 -height 40 \ -borderwidth 2 -relief raised -setgrid true \ -yscrollcommand {.t.scroll set}] scrollbar.t.scroll -command {.t.log yview} pack.t.scroll -side right -fill y pack.t.log -side left -fill both -expand true pack.t -side top -fill both -expand true

Master 1 ère année Sécurité des Systèmes Informatique 19 X Window Exemple Tcl/Tk # Run the program and arrange to read its input proc Run {} { global command input log machinename parentname if [catch {open "|$command |& cat"} input] { $log insert end $input\n } else { fileevent $input readable Log $log insert end $command\n } # Read and log ouput from the program proc Log {} { global input log if [eof $input] { Stop } else { gets $input line $log insert end $line\n $log see end } # Stop the program and fix up the button proc Stop {} { global input catch {close $input} } # Run the program and arrange to read its input proc Run {} { global command input log machinename parentname if [catch {open "|$command |& cat"} input] { $log insert end $input\n } else { fileevent $input readable Log $log insert end $command\n } # Read and log ouput from the program proc Log {} { global input log if [eof $input] { Stop } else { gets $input line $log insert end $line\n $log see end } # Stop the program and fix up the button proc Stop {} { global input catch {close $input} } # Add workstation proc Add {} { global realdir command machinename parentname set command "$realdir/nagios-ws.sh -ws $machinename -p $parentname add" Run } # Remove workstation proc Remove {} { global realdir command machinename parentname set command "$realdir/nagios-ws.sh -ws $machinename -p $parentname remove" Run } # Check configuration proc Check {} { global realdir command machinename parentname set command "$realdir/nagios-ws.sh -ws $machinename -p $parentname check" Run } # Service Restart proc Restart {} { global command set command "service nagios restart" Run } # Help proc Help {} { global realdir command machinename parentname set command "$realdir/nagios-ws.sh -h" Run #set command "echo nagios-ws.sh -ws $machinename -p $parentname" } # Add workstation proc Add {} { global realdir command machinename parentname set command "$realdir/nagios-ws.sh -ws $machinename -p $parentname add" Run } # Remove workstation proc Remove {} { global realdir command machinename parentname set command "$realdir/nagios-ws.sh -ws $machinename -p $parentname remove" Run } # Check configuration proc Check {} { global realdir command machinename parentname set command "$realdir/nagios-ws.sh -ws $machinename -p $parentname check" Run } # Service Restart proc Restart {} { global command set command "service nagios restart" Run } # Help proc Help {} { global realdir command machinename parentname set command "$realdir/nagios-ws.sh -h" Run #set command "echo nagios-ws.sh -ws $machinename -p $parentname" }

Master 1 ère année Sécurité des Systèmes Informatique 20 X Window Autre Exemple Tcl/Tk

Master 1 ère année Sécurité des Systèmes Informatique 21 X Window Autre Exemple Tcl/Tk #!/usr/bin/wish # db.sh GUI (Graphic User Interface). # $Id$ # Set window title wm title. "Save & Restore Database" # Default values set servername localhost set databasename NomBase set username NomUtilisateur set backupdir /data/backup # First frame : parameter fields frame.first -borderwidth 10 pack.first -side top -fill x label.first.srvlabel -text "Server Name:" -padx 0 entry.first.srvname -width 17 -relief sunken - textvariable servername label.first.dblabel -text " Database Name:" - padx 0 entry.first.dbname -width 17 -relief sunken - textvariable databasename label.first.usrlabel -text " User Name:" -padx 0 entry.first.usrname -width 17 -relief sunken - textvariable username pack.first.srvlabel.first.srvname -side left pack.first.dblabel.first.dbname -side left pack.first.usrlabel.first.usrname -side left #!/usr/bin/wish # db.sh GUI (Graphic User Interface). # $Id$ # Set window title wm title. "Save & Restore Database" # Default values set servername localhost set databasename NomBase set username NomUtilisateur set backupdir /data/backup # First frame : parameter fields frame.first -borderwidth 10 pack.first -side top -fill x label.first.srvlabel -text "Server Name:" -padx 0 entry.first.srvname -width 17 -relief sunken - textvariable servername label.first.dblabel -text " Database Name:" - padx 0 entry.first.dbname -width 17 -relief sunken - textvariable databasename label.first.usrlabel -text " User Name:" -padx 0 entry.first.usrname -width 17 -relief sunken - textvariable username pack.first.srvlabel.first.srvname -side left pack.first.dblabel.first.dbname -side left pack.first.usrlabel.first.usrname -side left # Create a frame for chosing backup file. frame.second -borderwidth 10 pack.second -side top -fill x label.second.filenamelabel -text "File name:" -padx 0 pack.second.filenamelabel -side left button.second.choosefile -text "Choose file" -command Choose pack.second.choosefile -side right entry.second.cmd -width 20 -relief sunken -textvariable filename pack.second.cmd -side left -fill x -expand true # Create a frame for buttons and entry. frame.third -borderwidth 10 pack.third -side top -fill x # Create the command buttons. label.third.databaselabel -text "Database commands:" -padx 0 button.third.save -text "Save" -command Save button.third.restore -text "Restore" -command Restore button.third.stop -text "Stop" -command StopDatabase pack.third.databaselabel.third.save.third.restore -side left button.third.help -text Help -command Help button.third.quit -text Quit -command exit pack.third.quit.third.help -side right # Create a text widget to log the output frame.t set log [text.t.log -width 80 -height 40 \ -borderwidth 2 -relief raised -setgrid true \ -yscrollcommand {.t.scroll set}] scrollbar.t.scroll -command {.t.log yview} pack.t.scroll -side right -fill y pack.t.log -side left -fill both -expand true pack.t -side top -fill both -expand true # Create a frame for chosing backup file. frame.second -borderwidth 10 pack.second -side top -fill x label.second.filenamelabel -text "File name:" -padx 0 pack.second.filenamelabel -side left button.second.choosefile -text "Choose file" -command Choose pack.second.choosefile -side right entry.second.cmd -width 20 -relief sunken -textvariable filename pack.second.cmd -side left -fill x -expand true # Create a frame for buttons and entry. frame.third -borderwidth 10 pack.third -side top -fill x # Create the command buttons. label.third.databaselabel -text "Database commands:" -padx 0 button.third.save -text "Save" -command Save button.third.restore -text "Restore" -command Restore button.third.stop -text "Stop" -command StopDatabase pack.third.databaselabel.third.save.third.restore -side left button.third.help -text Help -command Help button.third.quit -text Quit -command exit pack.third.quit.third.help -side right # Create a text widget to log the output frame.t set log [text.t.log -width 80 -height 40 \ -borderwidth 2 -relief raised -setgrid true \ -yscrollcommand {.t.scroll set}] scrollbar.t.scroll -command {.t.log yview} pack.t.scroll -side right -fill y pack.t.log -side left -fill both -expand true pack.t -side top -fill both -expand true

Master 1 ère année Sécurité des Systèmes Informatique 22 X Window Autre Exemple Tcl/Tk # Run the program and arrange to read its input proc Run {} { global command input log servername databasename username if [catch {open "|$command |& cat"} input] { $log insert end $input\n } else { fileevent $input readable Log $log insert end $command\n } # Read and log ouput from the program proc Log {} { global input log if [eof $input] { Stop } else { gets $input line $log insert end $line\n $log see end } # Stop the program and fix up the button proc Stop {} { global input catch {close $input} } # Run the program and arrange to read its input proc Run {} { global command input log servername databasename username if [catch {open "|$command |& cat"} input] { $log insert end $input\n } else { fileevent $input readable Log $log insert end $command\n } # Read and log ouput from the program proc Log {} { global input log if [eof $input] { Stop } else { gets $input line $log insert end $line\n $log see end } # Stop the program and fix up the button proc Stop {} { global input catch {close $input} } # Choose file proc Choose {} { global filename backupdir set directory "/data/backup" set types { {{Backup Files}{.backup}} {{All Files}*} } set filename [tk_getOpenFile -initialdir $backupdir - filetypes $types] } # Save database proc Save {} { global command servername databasename username set command "db.sh -srv $servername -db $databasename -usr $username save" Run } # Restore database proc Restore {} { global command servername databasename username filename if {$filename != ""} { set command "db.sh -srv $servername -db $databasename -usr $username -file $filename restore" Run } # Stop database proc StopDatabase {} { global command servername set command "ssh service postgresql status" Run } # Help proc Help {} { global command set command "db.sh -help" Run } # # Choose file proc Choose {} { global filename backupdir set directory "/data/backup" set types { {{Backup Files}{.backup}} {{All Files}*} } set filename [tk_getOpenFile -initialdir $backupdir - filetypes $types] } # Save database proc Save {} { global command servername databasename username set command "db.sh -srv $servername -db $databasename -usr $username save" Run } # Restore database proc Restore {} { global command servername databasename username filename if {$filename != ""} { set command "db.sh -srv $servername -db $databasename -usr $username -file $filename restore" Run } # Stop database proc StopDatabase {} { global command servername set command "ssh service postgresql status" Run } # Help proc Help {} { global command set command "db.sh -help" Run } #

Master 1 ère année Sécurité des Systèmes Informatique 23 Exemple shell #!/bin/sh # # Save databases # PROGNAME=`basename $0` SYNTAXE="Usage : $PROGNAME [-srv ] [-db ] [-file ] [-usr ] save | restore" EXAMPLE1="db.sh -db jabberd2 -srv srv54 -usr jabberd2 -file :01:42.backup restore" EXAMPLE2="db.sh -db jabberd2 -srv srv54 -usr jabberd2 save" # Initialisation DBSRV=database1 DBNAME=NomDeLaBase DBUSER=NomUtilisateur HEURE=`date +%Y%m%d-%T` BACKUPDIR=/data/backup PGBINDIR=/exe/pgsql/bin restore() { if [ ! -f $BACKUPFILE ]; then echo "$BACKUPFILE file doesn't exist!..." fi #!/bin/sh # # Save databases # PROGNAME=`basename $0` SYNTAXE="Usage : $PROGNAME [-srv ] [-db ] [-file ] [-usr ] save | restore" EXAMPLE1="db.sh -db jabberd2 -srv srv54 -usr jabberd2 -file :01:42.backup restore" EXAMPLE2="db.sh -db jabberd2 -srv srv54 -usr jabberd2 save" # Initialisation DBSRV=database1 DBNAME=NomDeLaBase DBUSER=NomUtilisateur HEURE=`date +%Y%m%d-%T` BACKUPDIR=/data/backup PGBINDIR=/exe/pgsql/bin restore() { if [ ! -f $BACKUPFILE ]; then echo "$BACKUPFILE file doesn't exist!..." fi echo "Deleting database..." $PGBINDIR/dropdb -h $DBSRV -p U $DBUSER $DBNAME STATUS=$? if [ $STATUS = 0 ]; then echo "Database deleted" else echo "ERROR CODE: $STATUS" echo "The database is not restored" exit $STATUS fi echo "Creating new database..." $PGBINDIR/createdb -h $DBSRV -p U $DBUSER $DBNAME STATUS=$? if [ $STATUS = 0 ]; then echo "Empty database created" else echo "ERROR CODE: $STATUS" echo "The new empty database is not created" exit $STATUS fi echo "Restoring $BACKUPFILE file in new database..." $PGBINDIR/pg_restore -i -h $DBSRV -p U $DBUSER -d $DBNAME -v "$BACKUPFILE" STATUS=$? if [ $STATUS = 0 ]; then echo "Database restored" else echo "The database is not restored" fi exit $STATUS } echo "Deleting database..." $PGBINDIR/dropdb -h $DBSRV -p U $DBUSER $DBNAME STATUS=$? if [ $STATUS = 0 ]; then echo "Database deleted" else echo "ERROR CODE: $STATUS" echo "The database is not restored" exit $STATUS fi echo "Creating new database..." $PGBINDIR/createdb -h $DBSRV -p U $DBUSER $DBNAME STATUS=$? if [ $STATUS = 0 ]; then echo "Empty database created" else echo "ERROR CODE: $STATUS" echo "The new empty database is not created" exit $STATUS fi echo "Restoring $BACKUPFILE file in new database..." $PGBINDIR/pg_restore -i -h $DBSRV -p U $DBUSER -d $DBNAME -v "$BACKUPFILE" STATUS=$? if [ $STATUS = 0 ]; then echo "Database restored" else echo "The database is not restored" fi exit $STATUS }

Master 1 ère année Sécurité des Systèmes Informatique 24 Exemple shell save() { BACKUPFILE=${BACKUPFILE:=$BACKUPDIR/$HEURE-$DBSRV- $DBNAME.backup} echo "Saving database..." if [ ! -d "$BACKUPDIR" ]; then mkdir -p $BACKUPDIR fi $PGBINDIR/pg_dump -i -h $DBSRV -p U $DBUSER -F c -b -v -f "$BACKUPFILE" $DBNAME STATUS=$? if [ $STATUS = 0 ]; then echo "Database saved" else echo "The database is not saved" fi exit $STATUS } while [ $# -gt 0 ] do case "$1" in -h | -help ) echo $SYNTAXE echo $EXAMPLE1 echo $EXAMPLE2 exit 0 ;; save() { BACKUPFILE=${BACKUPFILE:=$BACKUPDIR/$HEURE-$DBSRV- $DBNAME.backup} echo "Saving database..." if [ ! -d "$BACKUPDIR" ]; then mkdir -p $BACKUPDIR fi $PGBINDIR/pg_dump -i -h $DBSRV -p U $DBUSER -F c -b -v -f "$BACKUPFILE" $DBNAME STATUS=$? if [ $STATUS = 0 ]; then echo "Database saved" else echo "The database is not saved" fi exit $STATUS } while [ $# -gt 0 ] do case "$1" in -h | -help ) echo $SYNTAXE echo $EXAMPLE1 echo $EXAMPLE2 exit 0 ;; -db ) shift DBNAME=$1 shift ;; -file ) shift BACKUPFILE=$1 shift ;; -srv ) shift DBSRV=$1 shift ;; -usr ) shift DBUSER=$1 shift ;; * ) # Fonctions case "$1" in save | restore) FUNCTION=$1 $FUNCTION ;; *) echo $SYNTAXE echo $EXAMPLE exit 1 esac echo $SYNTAXE exit 1 ;; esac done -db ) shift DBNAME=$1 shift ;; -file ) shift BACKUPFILE=$1 shift ;; -srv ) shift DBSRV=$1 shift ;; -usr ) shift DBUSER=$1 shift ;; * ) # Fonctions case "$1" in save | restore) FUNCTION=$1 $FUNCTION ;; *) echo $SYNTAXE echo $EXAMPLE exit 1 esac echo $SYNTAXE exit 1 ;; esac done