There are essentially two distinct ways of how "to hack" (as a verb) or "hacker" (person who hacks) is used in the context of computing.
The more traditional—and positive—meaning emphasises the cleverness of the activity. Some examples about this use:
- The Hacker subculture article on Wikipedia
- The Jargon File – a glossary of hacker slang, which "illuminates many aspects of hackish tradition, folklore, and humor"
- People who work on the Linux kernel (generally speaking very smart and capable programmers), are commonly called "(Linux) kernel hackers".
In this context, another word, cracker (see definition 8), is often used in place of "hacker" to refer to those who "break computer security without authorization".
The other—negative—meaning, which is probably more recent (but not at all new) and more widespread, emphasises the illegality or lack of permission. In other words, "hacker" in this sense is the same as what "cracker" means in the hacker subculture mentioned above. :-) Example:
- The Hacker (computer security) article on Wikipedia states that "In common usage, a hacker is a person who breaks into computers and computer networks"
And yes, as you suggest, "to hack" can indeed also mean "to put together something that is clumsy and inelegant yet (somewhat) functional". (And as a noun "a hack" means the result of such work, i.e. a quick, somewhat ugly (possibly temporary) solution to a programming problem.)
But note that "hacker", to my understading, is rarely used in this sense of "to hack", i.e. to mean "someone who does quick inelegant solutions".
To sum it up, all three meanings you described indeed exist, and if you use the word you should be careful to establish the context clearly to avoid misunderstandings.
When talking with people outside the IT / software industry, "hacking" will most likely be understood to have the negative connotation (cracking illegally into systems). On the other hand, be aware that if faced with an audience full of (bearded) UNIX users, using the word "hacker" in the negative way could well earn you their disrespect. :-)