Wikipedia:Reference desk/Archives/Computing/2007 May 8

Computing desk
< May 7 << Apr | May | Jun >> May 9 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


May 8 edit

Random point in ImageJ edit

Hi

I'm trying to make a random point generator in ImageJ to randomly sample images. It should be really easy except I'm a biochemist. I've got:

//size of image in pixels
x = getWidth();
y = getHeight();
//first point
a=random()*x;
b=random()*y;
makeSelection("point", a, b);

But it comes up with "array expected [at "a"]". Does anyone know what I'm doing wrong. Aaadddaaammm 02:03, 8 May 2007 (UTC)[reply]

It looks like you need to declare the variables a and b. StuRat 03:02, 8 May 2007 (UTC)[reply]
Is that not the "a=..." and "b=..." lines? Aaadddaaammm 03:03, 8 May 2007 (UTC)[reply]
No, that's an assignment statement, I believe you want something like this (at least you would in C):
int a;
int b;
Try it at the beginning of the program. Without a declaration, the program doesn't know what type of variables they are, and seems to be assuming they are arrays. StuRat 03:05, 8 May 2007 (UTC)[reply]
Hmm... it doesn't like that: it says int is an "undefined variable". Aaadddaaammm 03:16, 8 May 2007 (UTC)[reply]
(ec) Let's wait until someone who actually knows about ImageJ comes along. I don't, and StuRat doesn't. (I don't think the problem is that the variables aren't declared, and even if that were the problem, the C-like declarations "int a;" and "int b;" would not be the way to declare them, because although ImageJ appears to be C-like, it's not that C-like.) —Steve Summit (talk) 03:30, 8 May 2007 (UTC)[reply]
Does random() return an array? —The preceding unsigned comment was added by 203.166.81.81 (talk) 03:24, 8 May 2007 (UTC).[reply]
I don't know. It works in this program, does it give u any clues?:
//length of line
length = 200;

//size of image in pixels
x=640;
y=480;

//start of line
a=random*x;
b=random*y;
//angle from start
c=random*2*PI;

//y coordinate of end
d=length*sin(c);
e=d+b;
while (e>y) {b=random*y; e=d+b;} //redo if point outside the image
while (e<0) {b=random*y; e=d+b;}

//x coordinate of end
f=length*cos(c);
g=f+a;
while (g>x) {a=random*x; g=f+a;}
while (g<0) {a=random*x; g=f+a;}
;

makeLine(a,b,g,e);
Aaadddaaammm 03:33, 8 May 2007 (UTC)[reply]
I notice that in the program that works, the reference is to random, not random(). —Steve Summit (talk) 03:39, 8 May 2007 (UTC)[reply]
Yea I was hoping I could just gloss over that. When I change it it makes no difference to either. This is what my random point code looks like now:
//size of image in pixels
x=640;
y=480;
//first point
a=random*x;
b=random*y;
makeSelection("point", a, b);

Aaadddaaammm 03:49, 8 May 2007 (UTC)[reply]

i don't know imagej but looking at the following example (from here)

x=newArray(1); y=newArray(1);
x[0]=90; y[0]=50;
makeSelection("point", x, y);

makes me think that you need to assign your variables like

a=newArray(1);
a[0]=random*x;

which would make the error message make sense because you are making a into an array. -- Diletante 04:31, 8 May 2007 (UTC)[reply]

If this is C++, and if random is a function, then random*x is very wrong, as random would be the position in memory of the function. --h2g2bob (talk) 18:18, 8 May 2007 (UTC)[reply]
Also, 203.166.81.81 (talk · contribs) is talking sense. Check if random() returns a number, an array, etc. --h2g2bob (talk) 18:22, 8 May 2007 (UTC)[reply]
I spent a little time this morning poking about in the documentation at the ImageJ site. In a nutshell, Diletante has it right. You have created variable a which is some random percentage of the x dimension, and variable b, similarly for the y dimension, however they are just numeric values. (From the documentation for the macro language, "Variables do not need to be declared and do not have explicit data types. They are automatically initialized when used in an assignment statement. A variable can contain a number, a string or an array.") Based on the description of the makeSelection function, the xcoord and ycoord arguments need to be numeric arrays. --LarryMac 13:44, 9 May 2007 (UTC)[reply]

SELinux edit

Isn't SELinux as vulnerable as the vulnerability of the root user account? If you are root, you can turn SELinux off, and so lose the benefits it gives you. Or am I missing something? 10:13, 8 May 2007 (UTC)

Certainly. On any Unix-like system, if you can become root, you can do anything. But that's a big "if" -- you're not supposed to be able to just "become root" at the drop of a hat. Theoretically, you can't become root unless you know root's password. In practice, you can maybe also become root if there's some bug you can exploit -- but the system has been very, very carefully scrutinized to try and make sure there aren't any bugs like that.
The other part of the puzzle is, how much time do you (the authorized user) have to spend as root doing authorized stuff, and how much of the time are you therefore vulnerable to being tricked into doing something you didn't want to do? Stated another way, how many programs are there that have to run as root, such that if they're exploited (perhaps by a buffer overflow attack), the system can be completely compromised?
Another aspect of SELinux (as I understand it) is that you don't have to spend nearly as much time as root, because there is a fine-grained permission scheme. For example, under normal Unix and Linux, if you want to open a privileged TCP port, you have to be root -- so if a program wants to open a privileged TCP port, it has to be root, and then it has to be written much more carefully so it can't be exploited. Under Unix variants with fine-grained permission schemes, on the other hand, you don't have to be root, you just need the "is allowed to open privileged ports" permission bit.
When fully realized, a system with fine-grained permission bits ought to allow you to all but eliminate the root account. You'd never have to log in as or su to root, and almost no programs would need to run as root, and you could set root's password to something you didn't even know. —Steve Summit (talk) 11:22, 8 May 2007 (UTC)[reply]
Thanks Steve. I suspected as much. Your answer was very helpful. 09:41, 9 May 2007 (UTC)
Addendum: I've been reading up on the "fine-grained permission bits" scheme, because at the moment I have a program that needs to open a privileged port, and I'd rather not run it as root. Under Unix, POSIX, and Linux, the permission bits are called "capabilities"; on a Linux machine you can read more about them by typing "man 7 capabilities". (Note, however, that according to our Capability-based security article, these Unix/POSIX/Linux capabilities are evidently not nearly as flexible or powerful as the capabilities in a true capability-based operating system.) The capability I want is called CAP_NET_BIND_SERVICE.
Unfortunately there's a "last mile" problem -- currently, effectively, the only way to give a process a capability is... to be root! (Cf. "begging the question". :-) ) Ideally, and eventually, there will be a way to assign capability bits to executable files in the filesystem, so that they will automatically receive those capabilities when they run. (This can be though of as a fine-grained setuid mechanism.) But there's obviously a lot of extra security concerns in terms of getting that mechanism exactly right (not to mention that it likely requires filesystem changes). —Steve Summit (talk) 12:29, 9 May 2007 (UTC)[reply]

Computer virus edit

I think my computer has a virus. VirusScan HAWK Alert keeps popping up messages saying that a virus is attempting to send emails. The subject lines in the emails are all about getting drugs. Please help me get rid of this virus.--71.185.129.251 14:36, 8 May 2007 (UTC)[reply]

If you're simply getting e-mails with a virus attachment, then just delete. Your computer has probably not been infected, unless the e-mails contain an exploit for your e-mail viewer. If you're already infected, run anti-virus. If you need a free web-based scanner, try this one: TrendMicro HouseCall. Splintercellguy 14:57, 8 May 2007 (UTC)[reply]
Well, no - as it "is attempting to send emails", then the machine is a zombie computer and has joined the almighty botnet. Run your antivirus software to fix this. --h2g2bob (talk)
There is good free software you can download to find and remove viruses/malware/spyware. I use AntiVir and it is one of the best (PDF report) anti-virus products available at the moment, and it is free for non-commercial use. I also use AdAware and Spybot - Search & Destroy to detect and remove malicious software (these are also freeware). You should also re-think your computer security. How did the virus get on your PC in the first place? --Phydaux 21:05, 8 May 2007 (UTC)[reply]

backup still running after three days edit

My XP laptop died suddenly on April 6; fortunately, I had a full C: backup only a few days old on an external hard drive. I bought a new PC with Vista home premium and immediately started having problem after problem; eventually I returned it to the store for a refund and bought another with the same OS.

But there were still more (but different, to keep it interesting :/ ) problems with the second new PC, starting before I restored the backup made from the first Vista machine to the second. Most or all (?) of the files were restored but the backup application also clobbered the built-in (logical) system recovery drive and did some other damage. Fortunately I had made system recovery DVDs and could safely remove that drive and recover from the other damage.

Comes time to do the weekly backup again (again using the native backup program on Vista and the same external hard drive). The backup has been running since Saturday noon, a full three days. The progress line indicates it is about 3/4 complete, and since it lists the names of files being backup up I can see that it is actually doing something. But why is it taking so long?

That's the first question. I assume the backup will complete in a day or so. The question then is, what to do? What should I be concerned about? What steps should I take to ensure a minimum of future trouble?

Also: I did a very stupid thing. The backup from the XP machine was a complete backup of C:. I restored it all to the first Vista machine. I don't recall if this is when my problems first started, but I'm sure it was a huge, if not the biggest, factor in all the trouble I've had. I hope the damage from that didn't carry over into my second Vista machine.

The backup of the first Vista machine didn't take that long, a few hours compared to days this second time.

BTW, I've unsuccessfully tried to find out how what exactly Vista backup backs up, by default. From the looks of the backup progress screen it looks like everything. Is that correct? --Halcatalyst 18:56, 8 May 2007 (UTC)[reply]

Some questions and notes:
  • What problems are occurring on the second Vista machine, other than the backup still being underway after three days?
  • What software did you use to back up your XP machine?
  • When you "restored it all to the first Vista machine", does this mean you restored the entire backup contents to a directory on the Vista machine, or that you replaced the whole Vista machine's hard disk with, basically, an image of the XP machine's hard disk, or that the XP backup's files were written willy-nilly to the Vista machine's hard disk?
    • The answer to that might determine what caused the problem. If you screwed up your first Vista machine's OS, then backed that disk up and then overwrote the second Vista machine's hard disk, then you've just copied a corrupted OS to the new machine.
Tempshill 13:29, 9 May 2007 (UTC)[reply]
  1. First of all, the backup completed today with no error messages. :-)
  2. I've used Windows Backup and Restore throughout: XP backup to an external hard drive; Vista restore to the first Vista machine (where I made the stupid mistake of overwriting the Vista OS). After this happened, I performed a system recovery. (Actually, more than one, but that's another story.) Then a Vista backup (standard), again to the external hard drive.+ At that point, I returned the first Vista machine to the store and bought another one. Then I ran Vista restore (standard) on the second Vista machine.
  1. The computer manufacturer has a knowledge base article which says Vista restore overwrites their protected D: system recovery drive. IOW, Vista restore just takes over any free space on that drive, corrupting it. However, since I had the recovery DVDs, I was able to safely delete D: This was with the help of the manufacturer's help desk.
  2. I would REALLY like to know just what Vista Backup and Restore do (what they back up and restore) in standard (default) mode. There is nothing on this in Vista Help.
  3. + Note: On the backup of the first Vista PC I also copied My Documents to a DVD and utilized an online backup service. However, when I tried to Restore All from the online service, it didn't work. The company admits it's their problem and calls the situation a show stopper. If they can figure out the solution, I am still willing to Restore All, because I've been doing my work in an area that would be unaffected by the download.
  1. I hope the above answers your third set of questions.
  2. The other main problem on the second machine was that the Hardware Diagnostics program was clobbered during the restore to the second Vista machine. The manufacturer's help desk told me I had to do a full system recovery, but when I inquired again by e-mail (where they have the leisure to look up knowledge base articles), the agent explained how I could recover parts of the system, in this case the hardware diagnostics program, using the system recovery DVDs I had made. However, in order to verify that the program now works, I have to a restart, which I have been unable to do because the backup took FOUR DAYS. I'll restart as soon as I post this message.
  3. Thank you for your interest in my problem! --Halcatalyst 19:59, 9 May 2007 (UTC)[reply]
  • After the computer restarted I was able to use Hardware Diagnostics to create a diagnostic boot disk. Now I'm going to check out the hardware. (I have no reason to think there's anything wrong with the hardware.) BTW, during that loooooooooooooooonnnnnng backup, 42GB on C: were backed up as 8GB on the external hard drive. --Halcatalyst 21:10, 9 May 2007 (UTC)[reply]