Archive for May, 2008

Install And Configure RLogin on CentOS 4

The below instructions for installing rlogin have been confirmed for CentOS. This means there is a very high probability it is compatible with a registered copy of Red Hat Enterprise Linux 4 (rhel4).

ENSURE RSH PACKAGES INSTALLED

The first step is to insure you have the correct packages installed. To do this, simply type the following in the terminal.

rpm -qa | grep -i rsh

The following should return two packages similar to:

rsh-server-0.17-25.3
rsh-0.17-25.3

If you are missing any of the above packages, run the code below to have the appropriate two rsh packages installed using yum.

yum install rsh*

EDIT FILE: /etc/xinetd.d/rsh
The most common changes are in red, though you should still confirm the rest of the file.

# default: off
# description:
# The rshd server is a server for the rcmd(3) routine and,
# consequently, for the rsh(1) program. The server provides
# remote execution facilities with authentication based on
# privileged port numbers from trusted hosts.
service shell
{
socket_type = stream
wait = no
user = root
log_on_success += USERID
log_on_failure += USERID
server = /usr/sbin/in.rshd
disable = no
}

EDIT FILE: /etc/xinetd.d/rlogin
The most common changes are in red, though you should still confirm the rest of the file.

# default: off
# description:
# Rlogind is a server for the rlogin program. The server provides remote
# execution with authentication based on privileged port numbers from trusted
# host
service login
{
socket_type = stream
wait = no
user = root
log_on_success += USERID
log_on_failure += USERID
server = /usr/sbin/in.rlogind
disable = no
}

EDIT FILE: /etc/xineted.d/rexec
The most common changes are in red, though you should still confirm the rest of the file.

# default: off
# description:
# Rexecd is the server for the rexec program. The server provides remote
# execution facilities with authentication based on user names and
# passwords.
service exec
{
socket_type = stream
wait = no
user = root
log_on_success += USERID
log_on_failure += USERID
server = /usr/sbin/in.rexecd
disable = no
}

EDIT FILE: /etc/securetty
The most common changes are in red, though you should still confirm the rest of the file.

console
vc/1
vc/2
vc/3
vc/4
vc/5
vc/6
vc/7
vc/8
vc/9
vc/10
vc/11
ttyS0
tty1
tty2
tty3
tty4
tty5
tty6
tty7
tty8
tty9
tty10
tty11
pts/0
pts/1
pts/2
pts/3
pts/4
pts/5
pts/6
pts/7
pts/8
pts/9
rsh
rlogin
rexec

RESTART THE RSH-SERVER SERVICE
To restart, one of the the following two commands below. One restarts the service while the other starts again.

/etc/init.d/xinetd start
/etc/init.d/xinetd restart

Random Integer Generator in Javascript

To generate a random number between 0 and X, use the below javascript:

var myRandomNumber = Math.floor(Math.random()*(X+1))

Therefore, if you want from 0 and 100, you simply need:

var myRandomNumber = Math.floor(Math.random()*101)

Now, a bit more complicated! If we want a number between the range of X and Y, follow the below formula:

var myRandomNumber = Math.floor(Math.random()*(Y-X))+X

And another real world example. Assume we want a random number from 79 and 473:

var myRandomNumber = Math.floor(Math.random()*394)+79

How to Deselect All From a RadioButtonList in C#

Unlike a list of check boxes, a list of radio buttons is designed to allow users to select only one option. However, once an option is selected for a radio button, it is now more difficult to deselect all options. However, a C# function ClearSelection, will allow the selection to be cleared.

In our example below is a RadioButtonList called rblSelectAOption:

<asp:RadioButtonList ID="rblSelectAOption" runat="server">
<asp:ListItem>One</asp:ListItem>
<asp:ListItem>Two</asp:ListItem>
<asp:ListItem>Three</asp:ListItem>
</asp:RadioButtonList>

Next, the codebehind below will clear all selected option:

rblSelectAOption.ClearSelection();

That’s all it takes!