This file is indexed.

/usr/sbin/perditiondb_odbc_makedb is in perdition-odbc 2.0-1ubuntu1.

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
#!/bin/bash
######################################################################
# makedb                                                    March 2002
# Horms                                             horms@verge.net.au
#
# Sample programme to seed a perdition database using ODBC
#
# perdition
# Mail retrieval proxy server ODBC 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

if [ -z "$(type -path isql)" ]; then
  echo "Could not find isql command. Bailing" >&2
  exit 1
fi


cat << __EOF__

ODBC should already be configured on a host. A DSN and user for perdition
to use should have been created.  This is typically done using the
underlying RDBMS.
__EOF__
echo -n "Has ODBC, a DSN and user been set up? [y/N]: "
read flim
if [ "$flim" != "y" -a "$flim" != "Y" ]; then
  echo Bailing...
  exit 0
fi

cat << __EOF__

The default host to connect to is $DEFAULT_DBSERVER.  To use this host hit
return. Otherwise enter a host to connect to.
__EOF__
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

cat << __EOF__

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

cat << __EOF__

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

cat << __EOF__

A user, other than root should be used to access the $dbname DSN. This user
should already exist in the underlying RDBMS and have query and insert
access to the $dbmname DSN. The default name for this user is
$DEFAULT_DBUSER. If you want to use this name, hit return, otherwise enter
the name for the user.
__EOF__
echo -n "Enter user [$DEFAULT_DBUSER]: "
read dbuser
if [ -z "$dbuser" ]; then
  dbuser="$DEFAULT_DBUSER"
fi

while [ 1 ]; do
  echo -n "Enter the 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
  break
done

echo
echo "Server: $dbserver"
echo "DSN:    $dbname"
echo "Table:  $dbtable"
echo "User:   $dbuser"
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 -n "Creating table $dbtable in database $dbname..."
#Seed table with data as user perdition

{
cat << __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__
} | isql "$dbname" "$dbuser" "$dbpw" >& /dev/null
if [ $? != 0 ]; then
  echo "Error creating $dbtable in $dbname. Bailing"
  exit 1
fi
echo " Done"

cat << __EOF__

You may now add entries to $dbtable in $dbname.
To connect to $dbname use:

isql "$dbname" "$dbuser" "$dbpw"

To insert rows into $dbtable use the following once
logged into $dbname

insert into $dbtable values (\"user\", \"servername\", \"port\");
where: 
  user:       name of user. Up to 128 characters. May not be NULL.
  servername: name of server for user. Up to 255 characters. May not be NULL.
  port:       port to connect to on server. May be NULL.
__EOF__