General
cancel
Showing results for 
Search instead for 
Did you mean: 

ftpd and language and date. How to change?

SOLVED
Go to solution
boje
Regular Advisor

ftpd and language and date. How to change?

Hi!

I have i problem i need to solve quick.
We have an application that does a FTP to one of our HP-UX machines. The ftp client can not interpret the date-line that is in our locale Swedish. In Swedish May is Maj. This was not a problem on our old Unix machines. If i use windows built in ftp-client and do ls -l it shows Maj 4 16:37 MYfile.foo
But with ssh it shows May 4 16:37 MYfile.foo

How can i change this for the ftpd?

Br
Patrik
10 REPLIES
Matti_Kurkela
Honored Contributor
Solution

Re: ftpd and language and date. How to change?

This is really one of the imperfections of the FTP standard: the exact date format was not specified in the original protocol specification. However, usually the client expects POSIX default behaviour, which can be arranged easily enough.

Your ftpd has inherited its locale environment variable settings from somewhere. Was it (re)started manually after a system boot? If so, the setting may have come from the session of the sysadmin that started it.

You need to set the LC_ALL environment variable for ftpd to explicitly override all locale definitions and force the POSIX standard behaviour in all language-related matters.

This setting is:

export LC_ALL="C"

See "man 5 environ", "man 5 lang" and "man locale" for more information.

Is your ftpd configured to run stand-alone or by inetd? (If stand-alone, the ftpd process is always running; if by inetd, only when someone has established a FTP connection.)

If your ftpd is started by inetd (the default set-up on HP-UX), you should place the locale setting (above) in the beginning of the /sbin/init.d/inetd script.
Then stop & restart inetd. All new ftpd processes should inherit the new setting from inetd.

If your ftpd runs stand-alone (e.g. the optional wu-ftpd from HP), place the locale setting in the beginning of the ftpd startup script, then stop and restart your ftpd.

MK
MK
Steven E. Protter
Exalted Contributor

Re: ftpd and language and date. How to change?

Shalom,

ftpd takes what it takes from the system default language.

Most people using ftp actually expect english prompts.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven Schweda
Honored Contributor

Re: ftpd and language and date. How to change?

> [...] All new ftpd processes [...]

If you don't want to make the change for
_everything_ inetd starts, then you might
try writing a wrapper script for ftpd, and
setting the desired environment in it before
it runs the real ftpd. Then edit inetd.conf
to run the wrapper script instead of the real
ftpd.
boje
Regular Advisor

Re: ftpd and language and date. How to change?

Hi Matti!

The ftpd ist started by indetd, and has an entry in the inetd.conf.
If i do export LC_ALL="C" as root and then do ineetd -c to restart ftpd, will it work?
Will the date show as "May" when a user list the files. This is rather important though the ftp-client can not download the files when the date is shown in swedish.

Br
Patrik
Matti_Kurkela
Honored Contributor

Re: ftpd and language and date. How to change?

No, "inetd -c" just sends a SIGHUP to the existing inetd process. That will cause it to re-read its configuration file (and nothing else). In this specific case, that is not enough.

In this case, you'll really need a "/sbin/init.d/inetd stop; /sbin/init.d/inetd start".

If you just set the LC_ALL environment variable in your session before restarting inetd, it will work. But the next time when someone is restarting inetd for any reason, that environment variable must be set *again* or the problem will reoccur.

Putting the "export LC_ALL=C" line into the /sbin/init.d/inetd script will make sure this problem goes away and will not come back to bite you again.

As far as I know, the locale settings are the *only* thing on a typical Unix system that can affect the language used in the timestamps. The POSIX standard locale "C" *mandates* US English-style timestamps.

Very recently, there was a similar thread regarding the timezone settings for ftpd... ah, found it:

http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1336789

MK
MK
boje
Regular Advisor

Re: ftpd and language and date. How to change?

Hi Matti!

I still do not understand.
I have two unix-boxes. The prod-box shows the date in Swedish when you do a ftp to it. Like "Maj" instead of "May".
And the test-box shows the date as "May" when i ftp to that box. And i can not find any difference in the locale or timezone settings on these boxes.
locale command shows the same on both boxes and the same user.

The working box:
$ locale
LANG=
LC_CTYPE="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_MESSAGES="C"
LC_ALL=

TZ=MET-1METDST

Non working box:
$ locale
LANG=
LC_CTYPE="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_MESSAGES="C"
LC_ALL=

TZ=MET-1METDST


Even the test-unix does not have the LC_ALL set. And this box is working.

Br
Patrik
boje
Regular Advisor

Re: ftpd and language and date. How to change?

Hi again!

I did test to set the export LC_ALL="C".
And locale shows it as "C".
Then i restarted inetd: /sbin/init.d/inetd stop and then start. But when i login to the ftp server it still shows the same.

Br
Patrik
Steven Schweda
Honored Contributor

Re: ftpd and language and date. How to change?

> locale command shows the same on both boxes
> and the same user.

The ftpd does not care what the locale is for
some random user. It cares what _its_ locale
is.

> May 4, 2009 16:44:20 GMT 2 pts

You may wish to think about that one again.
boje
Regular Advisor

Re: ftpd and language and date. How to change?

How do i change what_its_locale is?

How do i know what the difference is between these servers? One works and the other do not?

Writing a wrapper script is not an option, because i do not know how to do.

Br
Patrik
boje
Regular Advisor

Re: ftpd and language and date. How to change?

Hi all!

I am great full for you support. And i can now present you with the solution.
The file is: /etc/rc.config.d/LANG
And it contained:
LANG=sv_SE.utf8
export LANG

I removed these lines and restarted inetd.
Now it works. Thanks to my consultant Clas!

Br
Patrik