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
Line 
1#!/bin/bash
2#/**
3#@file    listclientlive
4#@brief   Lista la distribución ogLive asociada a los clientes, ya sea un equipo o un aula.
5#@usage   listclientlive Ambito
6#@param   Ambito    nombre de ordenador o nombre de aula
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
10#**/
11
12
13# Variables.
14OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
15SERVERCONF=$OPENGNSYS/etc/ogAdmServer.cfg
16TFTPDIR=$OPENGNSYS/tftpboot
17
18source $OPENGNSYS/lib/ogfunctions.sh || exit 1
19
20# Control básico de errores.
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"
26
27# Sustituir caracteres ' por \' para evitar inyección SQL.
28RESOURCE="${1//\'/\\\'}"
29# Obtener nombre de ordenador individual o todos los de una aula e indicar su plantilla asociada.
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';"
36
Note: See TracBrowser for help on using the repository browser.