Alias not working


 
Thread Tools Search this Thread
Operating Systems Solaris Alias not working
# 15  
Old 09-26-2014
Quote:
Originally Posted by Don Cragun
That depends on what system you're using.
The question being asked in the Solaris forum, /tmp standard permissions are protecting files created by someone to be altered by someone else, at least if the owner doesn't create world writable files (or if both users belong to the same group and the file is group writable).
"drwxrwxrwt" permissions for /tmp and /var/tmp is quite standard on Unix & Linux distributions nowadays.
# 16  
Old 09-26-2014
Quote:
Originally Posted by jlliagre
The question being asked in the Solaris forum, /tmp standard permissions are protecting files created by someone to be altered by someone else, at least if the owner doesn't create world writable files (or if both users belong to the same group and the file is group writable).
"drwxrwxrwt" permissions for /tmp and /var/tmp is quite standard on Unix & Linux distributions nowadays.
And, as I said, on a Solaris systems with normal permissions on /tmp, if I run wisecracker's script creating /tmp/ECHO and /tmp/PRINTF with my default umask and then you run wisecracker's script:
  • your attempts to create /tmp/ECHO and /tmp/PRINTF will fail, and
  • unless you're in the same group I'm in, you won't be able to read the /tmp/ECHO and /tmp/PRINTF that I created (which will either terminate your script with an error or set ECHO and PRINTF to empty strings; so
  • your attempts to run $ECHO or $PRINTF won't get you the echo or the printf utilities you wanted (although I don't know why you'd need to choose an alternative version of printf anyway). Instead they'd give your script syntax errors for trying to execute the unknown -e and \x1B[0m commands if your code didn't die on the failed printf and variable initialization commands.
  • And, of course, note that the -e option is not an option on Solaris /bin/echo either (it is a text operand to be printed).

What am I missing??? Why are you arguing that wisecracker's code provides a reasonable approach to solve the OP's problem? Given that any other user on the system can prevent you from creating an executable file in /tmp to be run by your script (just by running the same script with no malice intended), why do you think /tmp is an appropriate directory in which to install utilities (or files containing the paths of utilities) for use by any script that you want to run?
# 17  
Old 09-26-2014
Quote:
Originally Posted by Peasant
I would go with linkage in $HOME/bin or /opt/myapp/bin.
Why? If you know the location of the utility you want to run on the OS you're running on, just use it directly instead of dealing with the O&M of keeping copies of something that the OS provides.

Quote:
Also, check out your code, perhaps there is a way to make in run on every os using standard toolset, therefor avoiding linking, aliases and case / if clauses per OS.

If you can paste the code, folks here might be able to clear it up a bit so it works with standard tools.

For instance :
Code:
echo "hi" | grep -q "hi" && echo "YES"

Can be replaced with something like :
Code:
echo "hi" | grep "hi" > /dev/null && echo "YES"

Regards
Peasant.
Agreed. Avoid "proprietary" extensions - and GNUisms are no different than the extensions to standard protocols that Microsoft provides.

---------- Post updated at 10:10 AM ---------- Previous update was at 10:02 AM ----------

Quote:
Originally Posted by jlliagre
The question being asked in the Solaris forum, /tmp standard permissions are protecting files created by someone to be altered by someone else, at least if the owner doesn't create world writable files (or if both users belong to the same group and the file is group writable).
"drwxrwxrwt" permissions for /tmp and /var/tmp is quite standard on Unix & Linux distributions nowadays.
But that doesn't prevent someone from prepositioning malicious code in /tmp if they know you're going to run "/tmp/PRINTF".

I don't see the point of any complex workaround. Utilities behave differently on different flavors of Unix. You know what flavor you're running on, you know which utility you want run. The only way to deal with it is - get this - deal with it.

Deal with it directly and in ONE place - the script you're writing. Put in if/else or case statements for each OS flavor you support. Add comments to explain WHY you're using each utility from that location, because a few months or years from now, you won't remember. If you have a set of scripts, all of them can source ONE common script to set envvals for utilities.

Don't copy OS-provided binaries to custom locations - who's going to maintain that when the OS is updated?

Keep it simple - and in ONE place - or you won't be able to keep it working.
# 18  
Old 09-26-2014
Quote:
Originally Posted by achenle
Agreed. Avoid "proprietary" extensions - and GNUisms are no different than the extensions to standard protocols that Microsoft provides.
GNU is free, accurately documents which flags are extensions and which aren't, and does a good and pretty complete job of implementing standard features, so it's quite different from that sprawling monopoly. Some GNU extensions are just closing gaping holes which most UNIX suffers badly from -- like date math!

The real problem is that other UNIX cannot use these ideas to improve itself due to copyleft, so these improved features will never be anything but GNU Smilie Their hope, of course, was to entice people to switch to GNU by offering these feature improvements. In that way you could say they are similar I suppose, but I still see a difference between forcing someone into perpetual incompatibility and offering someone features they need. Oh well.

But this is besides the point... grep -q is POSIX. Maybe newer POSIX than some systems offer by default, but POSIX.
# 19  
Old 09-26-2014
Quote:
Originally Posted by Corona688
... ... ...
grep -q is POSIX. Maybe newer POSIX than some systems offer by default, but POSIX.
The grep -q option has been in POSIX since the first POSIX Shell and Utilities standard was adopted by IEEE in 1992. Any system with utilities conforming to any version of the Shell and Utilities volume of the POSIX standards for the last 22 years is required to support the -q option.
This User Gave Thanks to Don Cragun For This Post:
# 20  
Old 09-27-2014
Quote:
Originally Posted by Don Cragun
What am I missing??? Why are you arguing that wisecracker's code provides a reasonable approach to solve the OP's problem?
Not at all. Wisecracker's suggestion has several flaws and is obviously using a broken approach in the first place.
I was just commenting on your second statement "it is easy for them to replace the utilities you thought you had specified with other utilities of their choosing." In the general case, it is hopefully not easy or even possible for other users to modify or replace files you have previously created in /tmp. Many utilities and applications routinely create and use files in /tmp with no particular security risks. As I wrote and you later mentioned too, it is however possible to anticipate and create files with the same name in the first place but this is a case that can be easily detected by a robust script.
Quote:
Given that any other user on the system can prevent you from creating an executable file in /tmp to be run by your script (just by running the same script with no malice intended), why do you think /tmp is an appropriate directory in which to install utilities (or files containing the paths of utilities) for use by any script that you want to run?
I believe it is not necessarily inappropriate. There are a couple of advantages to use /tmp (or better /var/tmp if persistance is required) to store files and commands. As a matter of fact, I have been doing this on hundreds of machines for several decades without any major issue (outside the scripts being removed by erroneous cleaning procedures). Of course, some measures should be taken to avoid the race condition and other risks but if done properly, there are no fundamental issues.

---------- Post updated at 15:52 ---------- Previous update was at 13:29 ----------

Quote:
Originally Posted by Corona688
The real problem is that other UNIX cannot use these ideas to improve itself due to copyleft, so these improved features will never be anything but GNU.
I'm afraid this is incorrect. GNU which itself started by reimplementing commands and APIs found in proprietary Unix OSes doesn't forbid itself to reimplement GNUisms on non GPL code. What is forbidden by the GPL license is to reuse code, not ideas.
For example the -iname option has been added to the supported ones with the Solaris 11 standard find utility, same for the compression options like -z and -j with Solaris tar.
This User Gave Thanks to jlliagre For This Post:
# 21  
Old 09-27-2014
Crikey, apologies, I have opened up a real hornets nest here.
Quote:
You could go absolutely global......
I did quote 'absolutely global' not locally global, that is, storing inside one's $HOME drawer somewhere.
I use /tmp (C:\Windows\Temp, T:, etc depending on the platform) always when showing ideas and developing stuff.
Where else is universally common that usually has R/W(/X) access?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Lost with this alias why it is not working

Hi, I have the following aliases: $: alias | grep "^du=" du='du -s * 2>/dev/null | awk '\''{ printf "%4.2f-KB ==> %s \n", $1/1024 , $2 }'\'' | sort -rn' $: alias | grep "^dutop10=" dutop10='du -s * 2>/dev/null | awk '\''{ printf "%4.2f-KB ==> %s \n", $1/1024 , $2 }'\'' | sort -rn | head... (2 Replies)
Discussion started by: newbie_01
2 Replies

2. Shell Programming and Scripting

Alias not working

I have several shell scripts which contain the nawk command. Here is what i m doing assign the correct value to nawk as nawk is not found on a new systems. Here is what i did. more test.sh ] && alias nawk=/usr/bin/gawk ] && alias nawk=/usr/bin/nawk ] && alias nawk=/usr/bin/awk... (7 Replies)
Discussion started by: mohtashims
7 Replies

3. Solaris

Alias is not working under Bourne Shell

Hi, Please assist me why HC alias is not working under this shell? root@singapore # grep HC /.profile alias HC='cd /var/tmp/HC/2015/`date +%B`' root@singapore # . /.profile Sourcing //.profile-EIS..... root@singapore # echo $HC root@singapore # HC HC: not found root@singapore # echo... (18 Replies)
Discussion started by: tprabhu1983
18 Replies

4. Red Hat

[SOLVED] How the alias is working?

Iam facing some strange issue with alias. I have an alias file in which i have created lot of aliases as given below. export BUILD_HOME=/apps/psr/build export DB_HOME=/apps/psr/database export LOGS_HOME=/apps/psr/logs export BUILD_TEST=/apps/psr/build_dev/build_test export... (0 Replies)
Discussion started by: Vikram_Tanwar12
0 Replies

5. UNIX for Dummies Questions & Answers

cp command not working with alias

Hi Friends, I have added some aliases in .bash_profile file under the root folder. Its works fine and very useful, but does not go well with cp command. alias deploy="cd /usr/local/tomcat/webapp" alias artifacts="cd /usr/local/artifacts" but when i try to cp from artifacts folder... (2 Replies)
Discussion started by: prashdeep
2 Replies

6. Solaris

Simple question: alias not working for root

OS = Solaris 8 Issue: alias not working for root, but working for regular users # grep root /etc/passwd root:x:0:1:Super-User:/:/sbin/sh # alias dir=ls # dir dir: not found # alias dir="ls -l" # dir dir: not found # alias dir='ls -l' # dir dir: not found # alias... (2 Replies)
Discussion started by: aixlover
2 Replies

7. Solaris

Alias not working

Hello, I am trying to set an alias in my .kshrc or .profile and when I do it is not setting. If I do it manually it works fine. Is there another file I should put this in? Here is the alias I am using. alias ll='ls -ltr' I am using solaris 9. When I type alias it does not show these... (5 Replies)
Discussion started by: dkranes
5 Replies

8. UNIX for Dummies Questions & Answers

alias command not working after re-login

i create some alias in .cshrc file then i run source .cshrc to refresh it, the alias command work fine but when i relogin again, the alias command is not working... i need to re-run the source .cshrc command so that the alias only workable. any idea on it? (7 Replies)
Discussion started by: lsy
7 Replies

9. UNIX for Dummies Questions & Answers

alias not working in scripts

Hi All, PF below details, > cat run.sh #!/usr/bin/ksh alias ll="ls -l" > ./run.sh > ll ksh: ll: not found. Pls help on this? Thanks in Advance, Naga :cool: (2 Replies)
Discussion started by: Nagapandi
2 Replies

10. UNIX for Advanced & Expert Users

host alias not working: host not found

Hello, I am working on HP-UX , and in the /etc/hosts file we have setup an alias: aa.bb.cc.dd devmach2.unix.org devmach2 devma2v The alias devma2v does not work. Error when pinging devma2v ping: unknown host devma2v For devmach2 the ping works fine , returning the correct IP... (4 Replies)
Discussion started by: FunnyCats
4 Replies
Login or Register to Ask a Question