This file is indexed.

/usr/sbin/perditiondb_mysql_makedb is in perdition-mysql 2.2-3.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/bin/bash
######################################################################
# makedb                                                 December 2000
# Horms                                             horms@verge.net.au
#
# Frederic Delchambre                                     October 1999
# N.T.S. / Freegates                                dedel@freegates.be
#                                             http://www.freegates.be/
#                                                   http://www.nts.be/
#
# Sample programme to create a perdition database in a MySQL RDMS
#
# perdition
# Mail retrieval proxy server MySQL support
# Copyright (C) 1999-2005  Horms, Frederic Delchambre
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
######################################################################

DEFAULT_DBSERVER=localhost
DEFAULT_DBNAME=dbPerdition
DEFAULT_DBUSER=perdition
DEFAULT_DBHOST=localhost
DEFAULT_DBTABLE=tblPerdition

quit () {
  stty echo
}

trap quit HUP
trap quit TERM
trap quit STOP


echo
echo "MySQL should already be running on a host. The"
echo "default host is $DEFAULT_DBSERVER. To use this host"
echo "hit return. Otherwise enter a host to connect to."
echo -n "Enter host name [$DEFAULT_DBSERVER]: " >&2
read dbserver
if [ -z "$dbserver" ]; then
  dbserver="$DEFAULT_DBSERVER"
elif [ "$dbserver" != "localhost" ]; then
  DEFAULT_DBHOST="$(hostname)"
fi

echo
echo "The MySQL root user password should already be set."
echo "It is needed to add a MySQL perdition user that will"
echo "own the perdition database."
echo -n "Enter the password for the MySQL root user: " >&2
stty -echo
read rootpw
stty echo
echo

# Dummy command to check that we can loggin
mysqladmin --user=root --password="$rootpw" --host="$dbserver" ping
if [ $? != 0 ]; then
  echo "Error cannot connect to MySQL server using given password. Bailing" >&2
  exit 1
fi

echo
echo "Perdition information will be sotored in a separeate"
echo "database within the MySQL RDBMS. The default name for"
echo "this database is $DEFAULT_DBNAME. If you want to use this"
echo "hit return, otherwise enter the name for the database."
echo -n "Enter database name [$DEFAULT_DBNAME]: "
read dbname
if [ -z "$dbname" ]; then
  dbname="$DEFAULT_DBNAME"
fi

echo
echo "Perdition information will be stored in table in the"
echo "$dbname database. The default name for this table is"
echo "$DEFAULT_DBTABLE. If you want to use this hit return,"
echo "otherwise enter the name for the table."
echo -n "Enter table name [$DEFAULT_DBTABLE]: "
read dbtable
if [ -z "$dbtable" ]; then
  dbtable="$DEFAULT_DBTABLE"
fi

echo
echo "A MySQL user, other than root should be used to access"
echo "the $dbname database. The default name for this user"
echo "is $DEFAULT_DBUSER. If you want to use this name, hit return,"
echo "otherwise enter the name for the user."
echo -n "Enter database user [$DEFAULT_DBUSER]: "
read dbuser
if [ -z "$dbuser" ]; then
  dbuser="$DEFAULT_DBUSER"
fi

while [ 1 ]; do
  echo -n "Enter a password for the $dbuser user: " >&2
  stty -echo
  read dbpw
  stty echo
  echo
  if [ -z "$dbpw" ]; then
    echo "Password is empty, please try again." >& 2
    continue
  fi
  echo -n "Enter password again to verify: " >&2
  stty -echo
  read dbpw2
  stty echo
  echo
  if [ "$dbpw" != "$dbpw2" ]; then
    echo "Passwords do not match, please try again." >& 2
    continue
  fi
  break
done

echo
echo "It is desirable to restrict access to the $dbname database"
echo "by $dbuser to only be accepted from certain hosts. The default"
echo "is $DEFAULT_DBHOST. If you want to use this, hit return."
echo "otherwise enter host that $dbuser may connect from."
echo "The host may be a hostname or IP address and may contain the"
echo "SQL wildcard characters '%' and '_'. '%' matches zero or more"
echo "charcacters. '_' matches exactly one character."
echo -n "Enter hostname  [$DEFAULT_DBHOST]: "
read dbhost
if [ -z "$dbhost" ]; then
  dbhost="$DEFAULT_DBHOST"
fi

echo
echo "Database server:          $dbserver"
echo "Database name:            $dbname"
echo "Database table:           $dbtable"
echo "Database user:            $dbuser"
echo "Connections allowed from: $dbhost"
echo -n "Proceed (May destroy existing data in database) [y/n]? " >&2
read answer
if [ "$answer" != "y" -a "$answer" != "Y" ]; then
  exit 0
fi


echo
echo -n "Droping database $dbname... "
echo "drop database if exists $dbname;" | \
  mysql --user=root --password="$rootpw" --host="$dbserver" mysql 
if [ $? != 0 ]; then
  echo
  echo "Error. Bailing" >&2
  exit 1
fi
echo " Done"


echo -n "Creating database $dbname..."
mysqladmin --user=root --password="$rootpw" --host="$dbserver" create $dbname\
  > /dev/null
if [ $? != 0 ]; then
  echo
  echo "Error, Bailing" >&2
  exit 1
fi
echo " Done"


echo -n "Granting access to $dbname for user $dbuser..."
#Create user perdition in database
mysql --user=root --password="$rootpw" --host="$dbserver" mysql <<__EOF__
  GRANT ALL PRIVILEGES ON $dbname.* TO $dbuser@$dbhost
           IDENTIFIED BY '$dbpw' WITH GRANT OPTION;
__EOF__
if [ $? != 0 ]; then
  echo "Error granting access to $dbname for $dbuser. Bailing"
  exit 1
fi
echo " Done"


echo -n "Creating table $dbtable in database $dbname..."
#Seed table with data as user perdition
mysql --user="$dbuser" --password="$dbpw" "$dbname" --host="$dbserver" << _EOF_
drop table if exists $dbtable;
create table $dbtable (
  user varchar(128) not null primary key, 
  servername varchar(255) not null, 
  port varchar(8) default null
);
create index idx${dbtable}_user on $dbtable (user);
_EOF_
if [ $? != 0 ]; then
  echo "Error creating $dbtable in $dbname. Bailing"
  exit 1
fi
echo " Done"

echo
echo
echo "You may now add entries to $dbtable in $dbname."
echo "To connect to $dbname use:"
echo
echo "mysql --user=\"$dbuser\" --password=\"****\" --host=\"$dbserver\" \"$dbname\""
echo
echo "To insert rows into $dbtable use the following once"
echo "logged into $dbname"
echo
echo "insert into $dbtable values (\"user\", \"servername\", \"port\");"
echo "where: "
echo "  user:       name of user. Up to 128 characters. May not be NULL."
echo "  servername: name of server for user. Up to 255 characters. May not be NULL."
echo "  port:       port to connect to on server. May be NULL."