source: server/bin/listclientlive

qndtest
Last change on this file was 18eb8d6, checked in by Ramón M. Gómez <ramongomez@…>, 4 years ago

#958: Avoid SQL injection in addtodhcp and listclientlive.

  • Property mode set to 100755
File size: 1.3 KB
RevLine 
[5d28f39]1#!/bin/bash
[da6986dc]2#/**
3#@file    listclientlive
4#@brief   Lista la distribución ogLive asociada a los clientes, ya sea un equipo o un aula.
[18eb8d6]5#@usage   listclientlive Ambito
6#@param   Ambito    nombre de ordenador o nombre de aula
[da6986dc]7#@version 1.1.0 - Versión inicial basada en el script "listclientmode"
8#@author  Ramón M. Gómez, ETSII Universidad de Sevilla
9#@date    2017-06-01
[18eb8d6]10#**/
[5d28f39]11
12
13# Variables.
14OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
15SERVERCONF=$OPENGNSYS/etc/ogAdmServer.cfg
16TFTPDIR=$OPENGNSYS/tftpboot
[da6986dc]17
18source $OPENGNSYS/lib/ogfunctions.sh || exit 1
[5d28f39]19
20# Control básico de errores.
[da6986dc]21[ "$*" == "help" ] && help
22[ "$*" == "version" ] && version
23[ $# -eq 1 ] || raiseError usage
24[ "$USER" != "root" ] && raiseError access "Need to be root"
25source $SERVERCONF 2>/dev/null || raiseError access "Sin acceso a fichero de configuración"
[5d28f39]26
27# Sustituir caracteres ' por \' para evitar inyección SQL.
[18eb8d6]28RESOURCE="${1//\'/\\\'}"
[5d28f39]29# Obtener nombre de ordenador individual o todos los de una aula e indicar su plantilla asociada.
[da6986dc]30dbexec "SELECT CONCAT_WS('', 'Equipo \"', ord.nombreordenador, '\" asociado a cliente \"',
31               ord.oglivedir, '\"  $([ -e $TFTPDIR/$OGLIVE ] || echo "(inexistente)")')
32          FROM ordenadores AS ord
33          JOIN aulas USING (idaula)
34         WHERE aulas.nombreaula='$RESOURCE'
35            OR ord.nombreordenador='$RESOURCE';"
[5d28f39]36
Note: See TracBrowser for help on using the repository browser.